Merge lp:~ialastairhunter/nunitlite/categoryfilter into lp:nunitlite

Proposed by Tyrel Alastair Hunter
Status: Merged
Approved by: Charlie Poole
Approved revision: 145
Merged at revision: 145
Proposed branch: lp:~ialastairhunter/nunitlite/categoryfilter
Merge into: lp:nunitlite
Diff against target: 6121 lines (+3084/-2720)
19 files modified
src/framework/Api/ITest.cs (+103/-96)
src/framework/Api/ITestFilter.cs (+6/-1)
src/framework/Internal/Builders/NUnitTestCaseBuilder.cs (+406/-400)
src/framework/Internal/Filters/SimpleCategoryExpression.cs (+49/-0)
src/framework/Internal/RandomGenerator.cs (+184/-0)
src/framework/Internal/TestExecutionContext.cs (+622/-605)
src/framework/Internal/TestFilter.cs (+9/-1)
src/framework/Internal/Tests/Test.cs (+415/-404)
src/framework/Runner/CommandLineOptions.cs (+32/-2)
src/framework/Runner/TextUI.cs (+260/-237)
src/framework/TestContext.cs (+257/-249)
src/framework/nunitlite-2.0.csproj (+8/-6)
src/framework/nunitlite-3.5.csproj (+8/-6)
src/framework/nunitlite-4.0.csproj (+8/-6)
src/framework/nunitlite-4.5.csproj (+366/-364)
src/framework/nunitlite-netcf-2.0.csproj (+328/-326)
src/framework/nunitlite-netcf-3.5.csproj (+3/-1)
src/framework/nunitlite-sl-4.0.csproj (+10/-8)
src/framework/nunitlite-sl-5.0.csproj (+10/-8)
To merge this branch: bzr merge lp:~ialastairhunter/nunitlite/categoryfilter
Reviewer Review Type Date Requested Status
Charlie Poole code review Needs Fixing
Review via email: mp+161767@code.launchpad.net

Description of the change

Hello Charlie I would like you to review this code before I merge it into the main branch of nunitlite. This will give me some chance to learn how to complete a merge request before you leave on your trip. This branch contains all the functionality for simplified category expressions that we discussed

To post a comment you must log in.
144. By Tyrel Alastair Hunter

Added RandomGenerator to TestContext
RandomGenerator provides a repeatable method for obtaining random numbers during a tests execution
Added the seed for the random generator to ITest and Test so that the seed can be serialized to the results

145. By Tyrel Alastair Hunter

Merging Latest Changes from lp:nunitlite
tested category include and exlude options on netcf2, netcf3.5 net2, net3.5, net4, and net4.5

feature not supported on silverlight at this time
Fixed issue with RandomGenerator feature that caused for a compile Error when compiling NETC

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Just a few procedural comments before I actually review this...

1. It's generally best to use a separate branch per feature. This merge request actually fixes two unrelated bugs. Having them together means we have to either accept or postpone both of them, whereas it's very common to have different fixes follow different life cycles as new ideas come up, questions get asked, etc.

2. Something to do with end of line settings is messing us up here, making it look as if you have deleted and re-inserted very large selections of code. We should try to avoid this in the future. When the diff makes it clear what has changed, it's often possible to just look at the code to do the review. In this case, I'll have to merge your changes into a working directory and use some tools that will give a more meaningful diff. That takes longer.

With our current plan to do a release on the weekend, I'll just work with this merge as it is. The above is just info for the future. I'll be back later with the actual review.

Revision history for this message
Tyrel Alastair Hunter (ialastairhunter) wrote :

Thanks Charlie I believe what happened was the code I was given from the team was auto formatted by vs. normally I would try to only change the proper lines. In the future I will make seperate branches


Sent from Mailbox for iPhone

On Fri, May 3, 2013 at 5:52 PM, Charlie Poole <email address hidden> wrote:

> Just a few procedural comments before I actually review this...
> 1. It's generally best to use a separate branch per feature. This merge request actually fixes two unrelated bugs. Having them together means we have to either accept or postpone both of them, whereas it's very common to have different fixes follow different life cycles as new ideas come up, questions get asked, etc.
> 2. Something to do with end of line settings is messing us up here, making it look as if you have deleted and re-inserted very large selections of code. We should try to avoid this in the future. When the diff makes it clear what has changed, it's often possible to just look at the code to do the review. In this case, I'll have to merge your changes into a working directory and use some tools that will give a more meaningful diff. That takes longer.
> With our current plan to do a release on the weekend, I'll just work with this merge as it is. The above is just info for the future. I'll be back later with the actual review.
> --
> https://code.launchpad.net/~ialastairhunter/nunitlite/categoryfilter/+merge/161767
> You are the owner of lp:~ialastairhunter/nunitlite/categoryfilter.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Random Generator Change:

ITest has an unneeded (and undesirable) reference to the Internal namespace. Public APIs should avoid such references.

I see you use the Randomizer for the test method, which is used to generate random arguments, to create the seed for the user-side RandomGenerator. This will work well as far as guaranteeing a unique seed but introduces a dependency: adding or removing other tests will change the random seed used for any subsequently detected tests. Additionally, it defeats the lazy initialization of randomizers, forcing creation of a randomizer for every test method. I suggest we put it in this way but try to find a better approach that preserves lazy initialization of Randomizers and avoids test interactions.

Please add some comments that distinguish the purpose of RandomGenerator from Randomizer, now that we have both of them.

RandomGenerator won't compile under .NET 1.1 as it is. The GetEnums methods should all be controlled by #if CLR_2_0.

The portability logic for enums in RandomGenerator duplicates what's already in TypeHelper. See if you can use the TypeHelper enum methods - or add what's needed there.

I'm not seeing any tests for the new feature. It should be easy to copy and edit RandomizerTests.cs for this purpose. Harder to test repeatability, so maybe we should worry about that later.

Category Change:

Code looks good but I'm not seeing any tests here either. Should be easy to add to CommandLineOptionTests.cs.

Overall... It needs some fixes but you can go ahead and merge when you have done them.

review: Needs Fixing (code review)
Revision history for this message
Tyrel Alastair Hunter (ialastairhunter) wrote :

Random Generator Change:

ITest has an unneeded (and undesirable) reference to the Internal namespace. Public APIs should avoid such references.

I have removed this reference

I see you use the Randomizer for the test method, which is used to generate random arguments, to create the seed for the user-side RandomGenerator. This will work well as far as guaranteeing a unique seed but introduces a dependency: adding or removing other tests will change the random seed used for any subsequently detected tests. Additionally, it defeats the lazy initialization of randomizers, forcing creation of a randomizer for every test method. I suggest we put it in this way but try to find a better approach that preserves lazy initialization of Randomizers and avoids test interactions.

I am not sure i completely understand what you are saying here can we disuss this while we are doing the release at 2:00 EST

Please add some comments that distinguish the purpose of RandomGenerator from Randomizer, now that we have both of them.

Added comments to RandomGenerator and Randomizer

RandomGenerator won't compile under .NET 1.1 as it is. The GetEnums methods should all be controlled by #if CLR_2_0.

I believe that I fixed this however I will have you check it while we are doing the release at 2:00 EST

The portability logic for enums in RandomGenerator duplicates what's already in TypeHelper. See if you can use the TypeHelper enum methods - or add what's needed there.

Modified the code to use the TypeHelper instead

I'm not seeing any tests for the new feature. It should be easy to copy and edit RandomizerTests.cs for this purpose. Harder to test repeatability, so maybe we should worry about that later.

I have added tests for most of the functionality we can add more tests in a later release. Tests left out are for repeatability, and for the Random enum function

Category Change:

Code looks good but I'm not seeing any tests here either. Should be easy to add to CommandLineOptionTests.cs.

Overall... It needs some fixes but you can go ahead and merge when you have done them.

I have added tests to test that CommandLine Options works as expected. There is no test to ensure the options function correctly but the test ensure that the options are recognized.

we can add a test later that ensures that the options are used to modify the way nunit executes the tests.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

Hi Tyrel,

This all sounds good to me. I'm actually ready to start whenever you are.

Charlie

On Sat, May 4, 2013 at 10:02 AM, Tyrel Alastair Hunter <
<email address hidden>> wrote:

> Random Generator Change:
>
> ITest has an unneeded (and undesirable) reference to the Internal
> namespace. Public APIs should avoid such references.
>
> I have removed this reference
>
> I see you use the Randomizer for the test method, which is used to
> generate random arguments, to create the seed for the user-side
> RandomGenerator. This will work well as far as guaranteeing a unique seed
> but introduces a dependency: adding or removing other tests will change the
> random seed used for any subsequently detected tests. Additionally, it
> defeats the lazy initialization of randomizers, forcing creation of a
> randomizer for every test method. I suggest we put it in this way but try
> to find a better approach that preserves lazy initialization of Randomizers
> and avoids test interactions.
>
> I am not sure i completely understand what you are saying here can we
> disuss this while we are doing the release at 2:00 EST
>
> Please add some comments that distinguish the purpose of RandomGenerator
> from Randomizer, now that we have both of them.
>
> Added comments to RandomGenerator and Randomizer
>
> RandomGenerator won't compile under .NET 1.1 as it is. The GetEnums
> methods should all be controlled by #if CLR_2_0.
>
> I believe that I fixed this however I will have you check it while we are
> doing the release at 2:00 EST
>
> The portability logic for enums in RandomGenerator duplicates what's
> already in TypeHelper. See if you can use the TypeHelper enum methods - or
> add what's needed there.
>
> Modified the code to use the TypeHelper instead
>
> I'm not seeing any tests for the new feature. It should be easy to copy
> and edit RandomizerTests.cs for this purpose. Harder to test repeatability,
> so maybe we should worry about that later.
>
> I have added tests for most of the functionality we can add more tests in
> a later release. Tests left out are for repeatability, and for the Random
> enum function
>
> Category Change:
>
> Code looks good but I'm not seeing any tests here either. Should be easy
> to add to CommandLineOptionTests.cs.
>
> Overall... It needs some fixes but you can go ahead and merge when you
> have done them.
>
> I have added tests to test that CommandLine Options works as expected.
> There is no test to ensure the options function correctly but the test
> ensure that the options are recognized.
>
> we can add a test later that ensures that the options are used to modify
> the way nunit executes the tests.
> --
>
> https://code.launchpad.net/~ialastairhunter/nunitlite/categoryfilter/+merge/161767
> You are reviewing the proposed merge of
> lp:~ialastairhunter/nunitlite/categoryfilter into lp:nunitlite.
>

Revision history for this message
Tyrel Alastair Hunter (ialastairhunter) wrote :
Download full text (3.1 KiB)

I am on skype

Sent from Mailbox for iPhone

On Sat, May 4, 2013 at 1:43 PM, Charlie Poole <email address hidden> wrote:

> Hi Tyrel,
> This all sounds good to me. I'm actually ready to start whenever you are.
> Charlie
> On Sat, May 4, 2013 at 10:02 AM, Tyrel Alastair Hunter <
> <email address hidden>> wrote:
>> Random Generator Change:
>>
>> ITest has an unneeded (and undesirable) reference to the Internal
>> namespace. Public APIs should avoid such references.
>>
>> I have removed this reference
>>
>> I see you use the Randomizer for the test method, which is used to
>> generate random arguments, to create the seed for the user-side
>> RandomGenerator. This will work well as far as guaranteeing a unique seed
>> but introduces a dependency: adding or removing other tests will change the
>> random seed used for any subsequently detected tests. Additionally, it
>> defeats the lazy initialization of randomizers, forcing creation of a
>> randomizer for every test method. I suggest we put it in this way but try
>> to find a better approach that preserves lazy initialization of Randomizers
>> and avoids test interactions.
>>
>> I am not sure i completely understand what you are saying here can we
>> disuss this while we are doing the release at 2:00 EST
>>
>> Please add some comments that distinguish the purpose of RandomGenerator
>> from Randomizer, now that we have both of them.
>>
>> Added comments to RandomGenerator and Randomizer
>>
>> RandomGenerator won't compile under .NET 1.1 as it is. The GetEnums
>> methods should all be controlled by #if CLR_2_0.
>>
>> I believe that I fixed this however I will have you check it while we are
>> doing the release at 2:00 EST
>>
>> The portability logic for enums in RandomGenerator duplicates what's
>> already in TypeHelper. See if you can use the TypeHelper enum methods - or
>> add what's needed there.
>>
>> Modified the code to use the TypeHelper instead
>>
>> I'm not seeing any tests for the new feature. It should be easy to copy
>> and edit RandomizerTests.cs for this purpose. Harder to test repeatability,
>> so maybe we should worry about that later.
>>
>> I have added tests for most of the functionality we can add more tests in
>> a later release. Tests left out are for repeatability, and for the Random
>> enum function
>>
>> Category Change:
>>
>> Code looks good but I'm not seeing any tests here either. Should be easy
>> to add to CommandLineOptionTests.cs.
>>
>> Overall... It needs some fixes but you can go ahead and merge when you
>> have done them.
>>
>> I have added tests to test that CommandLine Options works as expected.
>> There is no test to ensure the options function correctly but the test
>> ensure that the options are recognized.
>>
>> we can add a test later that ensures that the options are used to modify
>> the way nunit executes the tests.
>> --
>>
>> https://code.launchpad.net/~ialastairhunter/nunitlite/categoryfilter/+merge/161767
>> You are reviewing the proposed merge of
>> lp:~ialastairhunter/nunitlite/categoryfilter into lp:nunitlite.
>>
> --
> https://code.launchpad.net/~ialastairhunter/nunitlite/categoryfilter/+merge/161767
> You are the owner of lp:~ialastairhunter/nun...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/framework/Api/ITest.cs'
2--- src/framework/Api/ITest.cs 2012-05-04 18:26:00 +0000
3+++ src/framework/Api/ITest.cs 2013-05-03 03:03:44 +0000
4@@ -1,96 +1,103 @@
5-// ***********************************************************************
6-// Copyright (c) 2007 Charlie Poole
7-//
8-// Permission is hereby granted, free of charge, to any person obtaining
9-// a copy of this software and associated documentation files (the
10-// "Software"), to deal in the Software without restriction, including
11-// without limitation the rights to use, copy, modify, merge, publish,
12-// distribute, sublicense, and/or sell copies of the Software, and to
13-// permit persons to whom the Software is furnished to do so, subject to
14-// the following conditions:
15-//
16-// The above copyright notice and this permission notice shall be
17-// included in all copies or substantial portions of the Software.
18-//
19-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26-// ***********************************************************************
27-
28-using System;
29-
30-namespace NUnit.Framework.Api
31-{
32- /// <summary>
33- /// Common interface supported by all representations
34- /// of a test. Only includes informational fields.
35- /// The Run method is specifically excluded to allow
36- /// for data-only representations of a test.
37- /// </summary>
38- public interface ITest : IXmlNodeBuilder
39- {
40- /// <summary>
41- /// Gets or sets the id of the test
42- /// </summary>
43- int Id { get; set; }
44-
45- /// <summary>
46- /// Gets the name of the test
47- /// </summary>
48- string Name { get; }
49-
50- /// <summary>
51- /// Gets the fully qualified name of the test
52- /// </summary>
53- string FullName { get; }
54-
55- /// <summary>
56- /// Gets the Type of the test fixture, if applicable, or
57- /// null if no fixture type is associated with this test.
58- /// </summary>
59- Type FixtureType { get; }
60-
61- /// <summary>
62- /// Indicates whether the test can be run using
63- /// the RunState enum.
64- /// </summary>
65- RunState RunState { get; set; }
66-
67- /// <summary>
68- /// Count of the test cases ( 1 if this is a test case )
69- /// </summary>
70- int TestCaseCount { get; }
71-
72- /// <summary>
73- /// Gets the properties of the test
74- /// </summary>
75- IPropertyBag Properties { get; }
76-
77- /// <summary>
78- /// Gets the parent test, if any.
79- /// </summary>
80- /// <value>The parent test or null if none exists.</value>
81- ITest Parent { get; }
82-
83- /// <summary>
84- /// Gets a bool indicating whether the current test
85- /// has any descendant tests.
86- /// </summary>
87- bool HasChildren { get; }
88-
89- /// <summary>
90- /// Gets this test's child tests
91- /// </summary>
92- /// <value>A list of child tests</value>
93-#if CLR_2_0 || CLR_4_0
94- System.Collections.Generic.IList<ITest> Tests { get; }
95-#else
96- System.Collections.IList Tests { get; }
97-#endif
98- }
99-}
100-
101+// ***********************************************************************
102+// Copyright (c) 2007 Charlie Poole
103+//
104+// Permission is hereby granted, free of charge, to any person obtaining
105+// a copy of this software and associated documentation files (the
106+// "Software"), to deal in the Software without restriction, including
107+// without limitation the rights to use, copy, modify, merge, publish,
108+// distribute, sublicense, and/or sell copies of the Software, and to
109+// permit persons to whom the Software is furnished to do so, subject to
110+// the following conditions:
111+//
112+// The above copyright notice and this permission notice shall be
113+// included in all copies or substantial portions of the Software.
114+//
115+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
116+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
117+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
118+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
119+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
120+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
121+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
122+// ***********************************************************************
123+
124+using System;
125+using NUnit.Framework.Internal;
126+
127+namespace NUnit.Framework.Api
128+{
129+ /// <summary>
130+ /// Common interface supported by all representations
131+ /// of a test. Only includes informational fields.
132+ /// The Run method is specifically excluded to allow
133+ /// for data-only representations of a test.
134+ /// </summary>
135+ public interface ITest : IXmlNodeBuilder
136+ {
137+ /// <summary>
138+ /// Gets or sets the id of the test
139+ /// </summary>
140+ int Id { get; set; }
141+
142+ /// <summary>
143+ /// Gets the name of the test
144+ /// </summary>
145+ string Name { get; }
146+
147+ /// <summary>
148+ /// Gets the fully qualified name of the test
149+ /// </summary>
150+ string FullName { get; }
151+
152+ /// <summary>
153+ /// Gets the Type of the test fixture, if applicable, or
154+ /// null if no fixture type is associated with this test.
155+ /// </summary>
156+ Type FixtureType { get; }
157+
158+ /// <summary>
159+ /// Indicates whether the test can be run using
160+ /// the RunState enum.
161+ /// </summary>
162+ RunState RunState { get; set; }
163+
164+ /// <summary>
165+ /// Count of the test cases ( 1 if this is a test case )
166+ /// </summary>
167+ int TestCaseCount { get; }
168+
169+ /// <summary>
170+ /// Gets the properties of the test
171+ /// </summary>
172+ IPropertyBag Properties { get; }
173+
174+ /// <summary>
175+ /// Gets the parent test, if any.
176+ /// </summary>
177+ /// <value>The parent test or null if none exists.</value>
178+ ITest Parent { get; }
179+
180+ /// <summary>
181+ /// Gets a bool indicating whether the current test
182+ /// has any descendant tests.
183+ /// </summary>
184+ bool HasChildren { get; }
185+
186+ /// <summary>
187+ /// Gets the Int value representing the seed for the RandomGenerator
188+ /// </summary>
189+ /// <value></value>
190+ int Seed { get; }
191+
192+ /// <summary>
193+ /// Gets this test's child tests
194+ /// </summary>
195+ /// <value>A list of child tests</value>
196+#if CLR_2_0 || CLR_4_0
197+ System.Collections.Generic.IList<ITest> Tests { get; }
198+#else
199+ System.Collections.IList Tests { get; }
200+#endif
201+ }
202+}
203+
204
205=== modified file 'src/framework/Api/ITestFilter.cs'
206--- src/framework/Api/ITestFilter.cs 2012-08-27 21:02:47 +0000
207+++ src/framework/Api/ITestFilter.cs 2013-05-03 03:03:44 +0000
208@@ -31,7 +31,12 @@
209 /// loaded, since this is the only time an ITest exists.
210 /// </summary>
211 public interface ITestFilter
212- {
213+ {
214+ /// <summary>
215+ /// Indicates whether this is the EmptyFilter
216+ /// </summary>
217+ bool IsEmpty { get; }
218+
219 /// <summary>
220 /// Determine if a particular test passes the filter criteria. Pass
221 /// may examine the parents and/or descendants of a test, depending
222
223=== modified file 'src/framework/Internal/Builders/NUnitTestCaseBuilder.cs'
224--- src/framework/Internal/Builders/NUnitTestCaseBuilder.cs 2012-10-08 22:37:39 +0000
225+++ src/framework/Internal/Builders/NUnitTestCaseBuilder.cs 2013-05-03 03:03:44 +0000
226@@ -1,400 +1,406 @@
227-// ***********************************************************************
228-// Copyright (c) 2008-2012 Charlie Poole
229-//
230-// Permission is hereby granted, free of charge, to any person obtaining
231-// a copy of this software and associated documentation files (the
232-// "Software"), to deal in the Software without restriction, including
233-// without limitation the rights to use, copy, modify, merge, publish,
234-// distribute, sublicense, and/or sell copies of the Software, and to
235-// permit persons to whom the Software is furnished to do so, subject to
236-// the following conditions:
237-//
238-// The above copyright notice and this permission notice shall be
239-// included in all copies or substantial portions of the Software.
240-//
241-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
242-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
243-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
244-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
245-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
246-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
247-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
248-// ***********************************************************************
249-
250-using System;
251-using System.Reflection;
252-using NUnit.Framework.Api;
253-using NUnit.Framework.Internal;
254-using NUnit.Framework.Extensibility;
255-using NUnit.Framework.Internal.Commands;
256-
257-#if NET_4_5
258-using System.Threading.Tasks;
259-#endif
260-
261-namespace NUnit.Framework.Builders
262-{
263- /// <summary>
264- /// Class to build ether a parameterized or a normal NUnitTestMethod.
265- /// There are four cases that the builder must deal with:
266- /// 1. The method needs no params and none are provided
267- /// 2. The method needs params and they are provided
268- /// 3. The method needs no params but they are provided in error
269- /// 4. The method needs params but they are not provided
270- /// This could have been done using two different builders, but it
271- /// turned out to be simpler to have just one. The BuildFrom method
272- /// takes a different branch depending on whether any parameters are
273- /// provided, but all four cases are dealt with in lower-level methods
274- /// </summary>
275- public class NUnitTestCaseBuilder : ITestCaseBuilder2
276- {
277-#if NUNITLITE
278- private ITestCaseProvider testCaseProvider = new TestCaseProviders();
279-#else
280- private ITestCaseProvider testCaseProvider = CoreExtensions.Host.TestCaseProviders;
281-#endif
282-
283- #region ITestCaseBuilder Methods
284- /// <summary>
285- /// Determines if the method can be used to build an NUnit test
286- /// test method of some kind. The method must normally be marked
287- /// with an identifying attriute for this to be true.
288- ///
289- /// Note that this method does not check that the signature
290- /// of the method for validity. If we did that here, any
291- /// test methods with invalid signatures would be passed
292- /// over in silence in the test run. Since we want such
293- /// methods to be reported, the check for validity is made
294- /// in BuildFrom rather than here.
295- /// </summary>
296- /// <param name="method">A MethodInfo for the method being used as a test method</param>
297- /// <returns>True if the builder can create a test case from this method</returns>
298- public bool CanBuildFrom(MethodInfo method)
299- {
300- return method.IsDefined(typeof(TestAttribute), false)
301- || method.IsDefined(typeof(ITestCaseSource), false)
302- || method.IsDefined(typeof(TheoryAttribute), false);
303- }
304-
305- /// <summary>
306- /// Build a Test from the provided MethodInfo. Depending on
307- /// whether the method takes arguments and on the availability
308- /// of test case data, this method may return a single test
309- /// or a group of tests contained in a ParameterizedMethodSuite.
310- /// </summary>
311- /// <param name="method">The MethodInfo for which a test is to be built</param>
312- /// <returns>A Test representing one or more method invocations</returns>
313- public Test BuildFrom(MethodInfo method)
314- {
315- return BuildFrom(method, null);
316- }
317-
318- #endregion
319-
320- #region ITestCaseBuilder2 Members
321-
322- /// <summary>
323- /// Determines if the method can be used to build an NUnit test
324- /// test method of some kind. The method must normally be marked
325- /// with an identifying attriute for this to be true.
326- ///
327- /// Note that this method does not check that the signature
328- /// of the method for validity. If we did that here, any
329- /// test methods with invalid signatures would be passed
330- /// over in silence in the test run. Since we want such
331- /// methods to be reported, the check for validity is made
332- /// in BuildFrom rather than here.
333- /// </summary>
334- /// <param name="method">A MethodInfo for the method being used as a test method</param>
335- /// <param name="parentSuite">The test suite being built, to which the new test would be added</param>
336- /// <returns>True if the builder can create a test case from this method</returns>
337- public bool CanBuildFrom(MethodInfo method, Test parentSuite)
338- {
339- return CanBuildFrom(method);
340- }
341-
342- /// <summary>
343- /// Build a Test from the provided MethodInfo. Depending on
344- /// whether the method takes arguments and on the availability
345- /// of test case data, this method may return a single test
346- /// or a group of tests contained in a ParameterizedMethodSuite.
347- /// </summary>
348- /// <param name="method">The MethodInfo for which a test is to be built</param>
349- /// <param name="parentSuite">The test fixture being populated, or null</param>
350- /// <returns>A Test representing one or more method invocations</returns>
351- public Test BuildFrom(MethodInfo method, Test parentSuite)
352- {
353- return testCaseProvider.HasTestCasesFor(method)
354- ? BuildParameterizedMethodSuite(method, parentSuite)
355- : BuildSingleTestMethod(method, parentSuite, null);
356- }
357-
358- #endregion
359-
360- #region Implementation
361-
362- /// <summary>
363- /// Builds a ParameterizedMetodSuite containing individual
364- /// test cases for each set of parameters provided for
365- /// this method.
366- /// </summary>
367- /// <param name="method">The MethodInfo for which a test is to be built</param>
368- /// <param name="parentSuite">The test suite for which the method is being built</param>
369- /// <returns>A ParameterizedMethodSuite populated with test cases</returns>
370- public Test BuildParameterizedMethodSuite(MethodInfo method, Test parentSuite)
371- {
372- ParameterizedMethodSuite methodSuite = new ParameterizedMethodSuite(method);
373- methodSuite.ApplyAttributesToTest(method);
374-
375- foreach (ITestCaseData testcase in testCaseProvider.GetTestCasesFor(method))
376- {
377- ParameterSet parms = testcase as ParameterSet;
378- if (parms == null)
379- parms = new ParameterSet(testcase);
380-
381- TestMethod test = BuildSingleTestMethod(method, parentSuite, parms);
382-
383- methodSuite.Add(test);
384- }
385-
386- return methodSuite;
387- }
388-
389- /// <summary>
390- /// Builds a single NUnitTestMethod, either as a child of the fixture
391- /// or as one of a set of test cases under a ParameterizedTestMethodSuite.
392- /// </summary>
393- /// <param name="method">The MethodInfo from which to construct the TestMethod</param>
394- /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
395- /// <param name="parms">The ParameterSet to be used, or null</param>
396- /// <returns></returns>
397- public static TestMethod BuildSingleTestMethod(MethodInfo method, Test parentSuite, ParameterSet parms)
398- {
399- TestMethod testMethod = new TestMethod(method, parentSuite);
400-
401- string prefix = method.ReflectedType.FullName;
402-
403- // Needed to give proper fullname to test in a parameterized fixture.
404- // Without this, the arguments to the fixture are not included.
405- if (parentSuite != null)
406- {
407- prefix = parentSuite.FullName;
408- //testMethod.FullName = prefix + "." + testMethod.Name;
409- }
410-
411- if (CheckTestMethodSignature(testMethod, parms))
412- {
413- if (parms == null)
414- testMethod.ApplyAttributesToTest(method);
415-
416- foreach (ICommandDecorator decorator in method.GetCustomAttributes(typeof(ICommandDecorator), true))
417- testMethod.CustomDecorators.Add(decorator);
418-
419- ExpectedExceptionAttribute[] attributes =
420- (ExpectedExceptionAttribute[])method.GetCustomAttributes(typeof(ExpectedExceptionAttribute), false);
421-
422- if (attributes.Length > 0)
423- {
424- ExpectedExceptionAttribute attr = attributes[0];
425- string handlerName = attr.Handler;
426- if (handlerName != null && GetExceptionHandler(testMethod.FixtureType, handlerName) == null)
427- MarkAsNotRunnable(
428- testMethod,
429- string.Format("The specified exception handler {0} was not found", handlerName));
430-
431- testMethod.CustomDecorators.Add(new ExpectedExceptionDecorator(attr.ExceptionData));
432- }
433- }
434-
435- if (parms != null)
436- {
437- // NOTE: After the call to CheckTestMethodSignature, the Method
438- // property of testMethod may no longer be the same as the
439- // original MethodInfo, so we reassign it here.
440- method = testMethod.Method;
441-
442- if (parms.TestName != null)
443- {
444- testMethod.Name = parms.TestName;
445- testMethod.FullName = prefix + "." + parms.TestName;
446- }
447- else if (parms.OriginalArguments != null)
448- {
449- string name = MethodHelper.GetDisplayName(method, parms.OriginalArguments);
450- testMethod.Name = name;
451- testMethod.FullName = prefix + "." + name;
452- }
453-
454- parms.ApplyToTest(testMethod);
455- }
456-
457- return testMethod;
458- }
459-
460- #endregion
461-
462- #region Helper Methods
463-
464- /// <summary>
465- /// Helper method that checks the signature of a TestMethod and
466- /// any supplied parameters to determine if the test is valid.
467- ///
468- /// Currently, NUnitTestMethods are required to be public,
469- /// non-abstract methods, either static or instance,
470- /// returning void. They may take arguments but the values must
471- /// be provided or the TestMethod is not considered runnable.
472- ///
473- /// Methods not meeting these criteria will be marked as
474- /// non-runnable and the method will return false in that case.
475- /// </summary>
476- /// <param name="testMethod">The TestMethod to be checked. If it
477- /// is found to be non-runnable, it will be modified.</param>
478- /// <param name="parms">Parameters to be used for this test, or null</param>
479- /// <returns>True if the method signature is valid, false if not</returns>
480- private static bool CheckTestMethodSignature(TestMethod testMethod, ParameterSet parms)
481- {
482- if (testMethod.Method.IsAbstract)
483- {
484- return MarkAsNotRunnable(testMethod, "Method is abstract");
485- }
486-
487- if (!testMethod.Method.IsPublic)
488- {
489- return MarkAsNotRunnable(testMethod, "Method is not public");
490- }
491-
492-#if NETCF
493- // TODO: Get this to work
494- if (testMethod.Method.IsGenericMethodDefinition)
495- {
496- return MarkAsNotRunnable(testMethod, "Generic test methods are not yet supported under .NET CF");
497- }
498-#endif
499-
500- ParameterInfo[] parameters = testMethod.Method.GetParameters();
501- int argsNeeded = parameters.Length;
502-
503- object[] arglist = null;
504- int argsProvided = 0;
505-
506- if (parms != null)
507- {
508- testMethod.parms = parms;
509- testMethod.RunState = parms.RunState;
510-
511- arglist = parms.Arguments;
512-
513- if (arglist != null)
514- argsProvided = arglist.Length;
515-
516- if (testMethod.RunState != RunState.Runnable)
517- return false;
518- }
519-
520- Type returnType = testMethod.Method.ReturnType;
521- if (returnType.Equals(typeof(void)))
522- {
523- if (parms != null && parms.HasExpectedResult)
524- return MarkAsNotRunnable(testMethod, "Method returning void cannot have an expected result");
525- }
526- else
527- {
528-#if NET_4_5
529- if (MethodHelper.IsAsyncMethod(testMethod.Method))
530- {
531- bool returnsGenericTask = returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task<>);
532- if (returnsGenericTask && (parms == null|| !parms.HasExpectedResult && !parms.ExceptionExpected))
533- return MarkAsNotRunnable(testMethod, "Async test method must have Task or void return type when no result is expected");
534- else if (!returnsGenericTask && parms != null && parms.HasExpectedResult)
535- return MarkAsNotRunnable(testMethod, "Async test method must have Task<T> return type when a result is expected");
536- }
537- else
538-#endif
539- if (parms == null || !parms.HasExpectedResult && !parms.ExceptionExpected)
540- return MarkAsNotRunnable(testMethod, "Method has non-void return value, but no result is expected");
541- }
542-
543- if (argsProvided > 0 && argsNeeded == 0)
544- {
545- return MarkAsNotRunnable(testMethod, "Arguments provided for method not taking any");
546- }
547-
548- if (argsProvided == 0 && argsNeeded > 0)
549- {
550- return MarkAsNotRunnable(testMethod, "No arguments were provided");
551- }
552-
553- if (argsProvided != argsNeeded)
554- {
555- return MarkAsNotRunnable(testMethod, "Wrong number of arguments provided");
556- }
557-
558-#if CLR_2_0 || CLR_4_0
559-#if !NETCF
560- if (testMethod.Method.IsGenericMethodDefinition)
561- {
562- Type[] typeArguments = GetTypeArgumentsForMethod(testMethod.Method, arglist);
563- foreach (object o in typeArguments)
564- if (o == null)
565- {
566- return MarkAsNotRunnable(testMethod, "Unable to determine type arguments for method");
567- }
568-
569- testMethod.method = testMethod.Method.MakeGenericMethod(typeArguments);
570- parameters = testMethod.Method.GetParameters();
571- }
572-#endif
573-#endif
574-
575- if (arglist != null && parameters != null)
576- TypeHelper.ConvertArgumentList(arglist, parameters);
577-
578- return true;
579- }
580-
581-#if CLR_2_0 || CLR_4_0
582-#if !NETCF
583- private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist)
584- {
585- Type[] typeParameters = method.GetGenericArguments();
586- Type[] typeArguments = new Type[typeParameters.Length];
587- ParameterInfo[] parameters = method.GetParameters();
588-
589- for (int typeIndex = 0; typeIndex < typeArguments.Length; typeIndex++)
590- {
591- Type typeParameter = typeParameters[typeIndex];
592-
593- for (int argIndex = 0; argIndex < parameters.Length; argIndex++)
594- {
595- if (parameters[argIndex].ParameterType.Equals(typeParameter))
596- typeArguments[typeIndex] = TypeHelper.BestCommonType(
597- typeArguments[typeIndex],
598- arglist[argIndex].GetType());
599- }
600- }
601-
602- return typeArguments;
603- }
604-#endif
605-#endif
606-
607- private static MethodInfo GetExceptionHandler(Type fixtureType, string name)
608- {
609- return fixtureType.GetMethod(
610- name,
611- BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
612- null,
613- new Type[] { typeof(System.Exception) },
614- null);
615- }
616-
617- private static bool MarkAsNotRunnable(TestMethod testMethod, string reason)
618- {
619- testMethod.RunState = RunState.NotRunnable;
620- testMethod.Properties.Set(PropertyNames.SkipReason, reason);
621- return false;
622- }
623-
624- #endregion
625- }
626-}
627+// ***********************************************************************
628+// Copyright (c) 2008-2012 Charlie Poole
629+//
630+// Permission is hereby granted, free of charge, to any person obtaining
631+// a copy of this software and associated documentation files (the
632+// "Software"), to deal in the Software without restriction, including
633+// without limitation the rights to use, copy, modify, merge, publish,
634+// distribute, sublicense, and/or sell copies of the Software, and to
635+// permit persons to whom the Software is furnished to do so, subject to
636+// the following conditions:
637+//
638+// The above copyright notice and this permission notice shall be
639+// included in all copies or substantial portions of the Software.
640+//
641+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
642+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
643+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
644+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
645+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
646+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
647+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
648+// ***********************************************************************
649+
650+using System;
651+using System.Reflection;
652+using NUnit.Framework.Api;
653+using NUnit.Framework.Internal;
654+using NUnit.Framework.Extensibility;
655+using NUnit.Framework.Internal.Commands;
656+
657+#if NET_4_5
658+using System.Threading.Tasks;
659+#endif
660+
661+namespace NUnit.Framework.Builders
662+{
663+ /// <summary>
664+ /// Class to build ether a parameterized or a normal NUnitTestMethod.
665+ /// There are four cases that the builder must deal with:
666+ /// 1. The method needs no params and none are provided
667+ /// 2. The method needs params and they are provided
668+ /// 3. The method needs no params but they are provided in error
669+ /// 4. The method needs params but they are not provided
670+ /// This could have been done using two different builders, but it
671+ /// turned out to be simpler to have just one. The BuildFrom method
672+ /// takes a different branch depending on whether any parameters are
673+ /// provided, but all four cases are dealt with in lower-level methods
674+ /// </summary>
675+ public class NUnitTestCaseBuilder : ITestCaseBuilder2
676+ {
677+#if NUNITLITE
678+ private ITestCaseProvider testCaseProvider = new TestCaseProviders();
679+#else
680+ private ITestCaseProvider testCaseProvider = CoreExtensions.Host.TestCaseProviders;
681+#endif
682+
683+ #region ITestCaseBuilder Methods
684+ /// <summary>
685+ /// Determines if the method can be used to build an NUnit test
686+ /// test method of some kind. The method must normally be marked
687+ /// with an identifying attriute for this to be true.
688+ ///
689+ /// Note that this method does not check that the signature
690+ /// of the method for validity. If we did that here, any
691+ /// test methods with invalid signatures would be passed
692+ /// over in silence in the test run. Since we want such
693+ /// methods to be reported, the check for validity is made
694+ /// in BuildFrom rather than here.
695+ /// </summary>
696+ /// <param name="method">A MethodInfo for the method being used as a test method</param>
697+ /// <returns>True if the builder can create a test case from this method</returns>
698+ public bool CanBuildFrom(MethodInfo method)
699+ {
700+ return method.IsDefined(typeof(TestAttribute), false)
701+ || method.IsDefined(typeof(ITestCaseSource), false)
702+ || method.IsDefined(typeof(TheoryAttribute), false);
703+ }
704+
705+ /// <summary>
706+ /// Build a Test from the provided MethodInfo. Depending on
707+ /// whether the method takes arguments and on the availability
708+ /// of test case data, this method may return a single test
709+ /// or a group of tests contained in a ParameterizedMethodSuite.
710+ /// </summary>
711+ /// <param name="method">The MethodInfo for which a test is to be built</param>
712+ /// <returns>A Test representing one or more method invocations</returns>
713+ public Test BuildFrom(MethodInfo method)
714+ {
715+ return BuildFrom(method, null);
716+ }
717+
718+ #endregion
719+
720+ #region ITestCaseBuilder2 Members
721+
722+ /// <summary>
723+ /// Determines if the method can be used to build an NUnit test
724+ /// test method of some kind. The method must normally be marked
725+ /// with an identifying attriute for this to be true.
726+ ///
727+ /// Note that this method does not check that the signature
728+ /// of the method for validity. If we did that here, any
729+ /// test methods with invalid signatures would be passed
730+ /// over in silence in the test run. Since we want such
731+ /// methods to be reported, the check for validity is made
732+ /// in BuildFrom rather than here.
733+ /// </summary>
734+ /// <param name="method">A MethodInfo for the method being used as a test method</param>
735+ /// <param name="parentSuite">The test suite being built, to which the new test would be added</param>
736+ /// <returns>True if the builder can create a test case from this method</returns>
737+ public bool CanBuildFrom(MethodInfo method, Test parentSuite)
738+ {
739+ return CanBuildFrom(method);
740+ }
741+
742+ /// <summary>
743+ /// Build a Test from the provided MethodInfo. Depending on
744+ /// whether the method takes arguments and on the availability
745+ /// of test case data, this method may return a single test
746+ /// or a group of tests contained in a ParameterizedMethodSuite.
747+ /// </summary>
748+ /// <param name="method">The MethodInfo for which a test is to be built</param>
749+ /// <param name="parentSuite">The test fixture being populated, or null</param>
750+ /// <returns>A Test representing one or more method invocations</returns>
751+ public Test BuildFrom(MethodInfo method, Test parentSuite)
752+ {
753+ return testCaseProvider.HasTestCasesFor(method)
754+ ? BuildParameterizedMethodSuite(method, parentSuite)
755+ : BuildSingleTestMethod(method, parentSuite, null);
756+ }
757+
758+ #endregion
759+
760+ #region Implementation
761+
762+ /// <summary>
763+ /// Builds a ParameterizedMetodSuite containing individual
764+ /// test cases for each set of parameters provided for
765+ /// this method.
766+ /// </summary>
767+ /// <param name="method">The MethodInfo for which a test is to be built</param>
768+ /// <param name="parentSuite">The test suite for which the method is being built</param>
769+ /// <returns>A ParameterizedMethodSuite populated with test cases</returns>
770+ public Test BuildParameterizedMethodSuite(MethodInfo method, Test parentSuite)
771+ {
772+ ParameterizedMethodSuite methodSuite = new ParameterizedMethodSuite(method);
773+ methodSuite.ApplyAttributesToTest(method);
774+
775+ foreach (ITestCaseData testcase in testCaseProvider.GetTestCasesFor(method))
776+ {
777+ ParameterSet parms = testcase as ParameterSet;
778+ if (parms == null)
779+ parms = new ParameterSet(testcase);
780+
781+ TestMethod test = BuildSingleTestMethod(method, parentSuite, parms);
782+
783+ methodSuite.Add(test);
784+ }
785+
786+ return methodSuite;
787+ }
788+
789+ /// <summary>
790+ /// Builds a single NUnitTestMethod, either as a child of the fixture
791+ /// or as one of a set of test cases under a ParameterizedTestMethodSuite.
792+ /// </summary>
793+ /// <param name="method">The MethodInfo from which to construct the TestMethod</param>
794+ /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
795+ /// <param name="parms">The ParameterSet to be used, or null</param>
796+ /// <returns></returns>
797+ public static TestMethod BuildSingleTestMethod(MethodInfo method, Test parentSuite, ParameterSet parms)
798+ {
799+ TestMethod testMethod = new TestMethod(method, parentSuite);
800+#if !NETCF
801+ Randomizer randomizer = Randomizer.GetRandomizer(MethodBase.GetCurrentMethod());
802+#else
803+ Randomizer randomizer = Randomizer.GetRandomizer(typeof(NUnitTestCaseBuilder).GetMethod("BuildSingleTestMethod"));
804+#endif
805+ testMethod.Seed = randomizer.Next();
806+
807+ string prefix = method.ReflectedType.FullName;
808+
809+ // Needed to give proper fullname to test in a parameterized fixture.
810+ // Without this, the arguments to the fixture are not included.
811+ if (parentSuite != null)
812+ {
813+ prefix = parentSuite.FullName;
814+ //testMethod.FullName = prefix + "." + testMethod.Name;
815+ }
816+
817+ if (CheckTestMethodSignature(testMethod, parms))
818+ {
819+ if (parms == null)
820+ testMethod.ApplyAttributesToTest(method);
821+
822+ foreach (ICommandDecorator decorator in method.GetCustomAttributes(typeof(ICommandDecorator), true))
823+ testMethod.CustomDecorators.Add(decorator);
824+
825+ ExpectedExceptionAttribute[] attributes =
826+ (ExpectedExceptionAttribute[])method.GetCustomAttributes(typeof(ExpectedExceptionAttribute), false);
827+
828+ if (attributes.Length > 0)
829+ {
830+ ExpectedExceptionAttribute attr = attributes[0];
831+ string handlerName = attr.Handler;
832+ if (handlerName != null && GetExceptionHandler(testMethod.FixtureType, handlerName) == null)
833+ MarkAsNotRunnable(
834+ testMethod,
835+ string.Format("The specified exception handler {0} was not found", handlerName));
836+
837+ testMethod.CustomDecorators.Add(new ExpectedExceptionDecorator(attr.ExceptionData));
838+ }
839+ }
840+
841+ if (parms != null)
842+ {
843+ // NOTE: After the call to CheckTestMethodSignature, the Method
844+ // property of testMethod may no longer be the same as the
845+ // original MethodInfo, so we reassign it here.
846+ method = testMethod.Method;
847+
848+ if (parms.TestName != null)
849+ {
850+ testMethod.Name = parms.TestName;
851+ testMethod.FullName = prefix + "." + parms.TestName;
852+ }
853+ else if (parms.OriginalArguments != null)
854+ {
855+ string name = MethodHelper.GetDisplayName(method, parms.OriginalArguments);
856+ testMethod.Name = name;
857+ testMethod.FullName = prefix + "." + name;
858+ }
859+
860+ parms.ApplyToTest(testMethod);
861+ }
862+
863+ return testMethod;
864+ }
865+
866+ #endregion
867+
868+ #region Helper Methods
869+
870+ /// <summary>
871+ /// Helper method that checks the signature of a TestMethod and
872+ /// any supplied parameters to determine if the test is valid.
873+ ///
874+ /// Currently, NUnitTestMethods are required to be public,
875+ /// non-abstract methods, either static or instance,
876+ /// returning void. They may take arguments but the values must
877+ /// be provided or the TestMethod is not considered runnable.
878+ ///
879+ /// Methods not meeting these criteria will be marked as
880+ /// non-runnable and the method will return false in that case.
881+ /// </summary>
882+ /// <param name="testMethod">The TestMethod to be checked. If it
883+ /// is found to be non-runnable, it will be modified.</param>
884+ /// <param name="parms">Parameters to be used for this test, or null</param>
885+ /// <returns>True if the method signature is valid, false if not</returns>
886+ private static bool CheckTestMethodSignature(TestMethod testMethod, ParameterSet parms)
887+ {
888+ if (testMethod.Method.IsAbstract)
889+ {
890+ return MarkAsNotRunnable(testMethod, "Method is abstract");
891+ }
892+
893+ if (!testMethod.Method.IsPublic)
894+ {
895+ return MarkAsNotRunnable(testMethod, "Method is not public");
896+ }
897+
898+#if NETCF
899+ // TODO: Get this to work
900+ if (testMethod.Method.IsGenericMethodDefinition)
901+ {
902+ return MarkAsNotRunnable(testMethod, "Generic test methods are not yet supported under .NET CF");
903+ }
904+#endif
905+
906+ ParameterInfo[] parameters = testMethod.Method.GetParameters();
907+ int argsNeeded = parameters.Length;
908+
909+ object[] arglist = null;
910+ int argsProvided = 0;
911+
912+ if (parms != null)
913+ {
914+ testMethod.parms = parms;
915+ testMethod.RunState = parms.RunState;
916+
917+ arglist = parms.Arguments;
918+
919+ if (arglist != null)
920+ argsProvided = arglist.Length;
921+
922+ if (testMethod.RunState != RunState.Runnable)
923+ return false;
924+ }
925+
926+ Type returnType = testMethod.Method.ReturnType;
927+ if (returnType.Equals(typeof(void)))
928+ {
929+ if (parms != null && parms.HasExpectedResult)
930+ return MarkAsNotRunnable(testMethod, "Method returning void cannot have an expected result");
931+ }
932+ else
933+ {
934+#if NET_4_5
935+ if (MethodHelper.IsAsyncMethod(testMethod.Method))
936+ {
937+ bool returnsGenericTask = returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task<>);
938+ if (returnsGenericTask && (parms == null|| !parms.HasExpectedResult && !parms.ExceptionExpected))
939+ return MarkAsNotRunnable(testMethod, "Async test method must have Task or void return type when no result is expected");
940+ else if (!returnsGenericTask && parms != null && parms.HasExpectedResult)
941+ return MarkAsNotRunnable(testMethod, "Async test method must have Task<T> return type when a result is expected");
942+ }
943+ else
944+#endif
945+ if (parms == null || !parms.HasExpectedResult && !parms.ExceptionExpected)
946+ return MarkAsNotRunnable(testMethod, "Method has non-void return value, but no result is expected");
947+ }
948+
949+ if (argsProvided > 0 && argsNeeded == 0)
950+ {
951+ return MarkAsNotRunnable(testMethod, "Arguments provided for method not taking any");
952+ }
953+
954+ if (argsProvided == 0 && argsNeeded > 0)
955+ {
956+ return MarkAsNotRunnable(testMethod, "No arguments were provided");
957+ }
958+
959+ if (argsProvided != argsNeeded)
960+ {
961+ return MarkAsNotRunnable(testMethod, "Wrong number of arguments provided");
962+ }
963+
964+#if CLR_2_0 || CLR_4_0
965+#if !NETCF
966+ if (testMethod.Method.IsGenericMethodDefinition)
967+ {
968+ Type[] typeArguments = GetTypeArgumentsForMethod(testMethod.Method, arglist);
969+ foreach (object o in typeArguments)
970+ if (o == null)
971+ {
972+ return MarkAsNotRunnable(testMethod, "Unable to determine type arguments for method");
973+ }
974+
975+ testMethod.method = testMethod.Method.MakeGenericMethod(typeArguments);
976+ parameters = testMethod.Method.GetParameters();
977+ }
978+#endif
979+#endif
980+
981+ if (arglist != null && parameters != null)
982+ TypeHelper.ConvertArgumentList(arglist, parameters);
983+
984+ return true;
985+ }
986+
987+#if CLR_2_0 || CLR_4_0
988+#if !NETCF
989+ private static Type[] GetTypeArgumentsForMethod(MethodInfo method, object[] arglist)
990+ {
991+ Type[] typeParameters = method.GetGenericArguments();
992+ Type[] typeArguments = new Type[typeParameters.Length];
993+ ParameterInfo[] parameters = method.GetParameters();
994+
995+ for (int typeIndex = 0; typeIndex < typeArguments.Length; typeIndex++)
996+ {
997+ Type typeParameter = typeParameters[typeIndex];
998+
999+ for (int argIndex = 0; argIndex < parameters.Length; argIndex++)
1000+ {
1001+ if (parameters[argIndex].ParameterType.Equals(typeParameter))
1002+ typeArguments[typeIndex] = TypeHelper.BestCommonType(
1003+ typeArguments[typeIndex],
1004+ arglist[argIndex].GetType());
1005+ }
1006+ }
1007+
1008+ return typeArguments;
1009+ }
1010+#endif
1011+#endif
1012+
1013+ private static MethodInfo GetExceptionHandler(Type fixtureType, string name)
1014+ {
1015+ return fixtureType.GetMethod(
1016+ name,
1017+ BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
1018+ null,
1019+ new Type[] { typeof(System.Exception) },
1020+ null);
1021+ }
1022+
1023+ private static bool MarkAsNotRunnable(TestMethod testMethod, string reason)
1024+ {
1025+ testMethod.RunState = RunState.NotRunnable;
1026+ testMethod.Properties.Set(PropertyNames.SkipReason, reason);
1027+ return false;
1028+ }
1029+
1030+ #endregion
1031+ }
1032+}
1033
1034=== added file 'src/framework/Internal/Filters/SimpleCategoryExpression.cs'
1035--- src/framework/Internal/Filters/SimpleCategoryExpression.cs 1970-01-01 00:00:00 +0000
1036+++ src/framework/Internal/Filters/SimpleCategoryExpression.cs 2013-05-03 03:03:44 +0000
1037@@ -0,0 +1,49 @@
1038+using System;
1039+using System.Collections.Generic;
1040+using System.Text;
1041+using NUnit.Framework.Internal;
1042+using NUnit.Framework.Internal.Filters;
1043+
1044+namespace NUnit.Framework.Internal.Filters
1045+{
1046+ /// <summary>
1047+ /// SimpleCategoryFilter parses a basic string representing a
1048+ /// single category or a list of categories separated by commas
1049+ /// </summary>
1050+ public class SimpleCategoryExpression
1051+ {
1052+ private string text;
1053+
1054+ private TestFilter filter;
1055+
1056+ /// <summary>
1057+ /// Construct category filter from a text string
1058+ /// </summary>
1059+ /// <param name="text">A list of categories to parse</param>
1060+ public SimpleCategoryExpression(string text)
1061+ {
1062+ this.text = text;
1063+ }
1064+
1065+ /// <summary>
1066+ /// Gets the TestFilter represented by the expression
1067+ /// </summary>
1068+ public TestFilter Filter
1069+ {
1070+ get
1071+ {
1072+ if (filter == null)
1073+ {
1074+ filter = GetCategories();
1075+ }
1076+ return filter;
1077+ }
1078+ }
1079+
1080+ private TestFilter GetCategories()
1081+ {
1082+ string[] categories = text.Split(',');
1083+ return new CategoryFilter(categories);
1084+ }
1085+ }
1086+}
1087
1088=== added file 'src/framework/Internal/RandomGenerator.cs'
1089--- src/framework/Internal/RandomGenerator.cs 1970-01-01 00:00:00 +0000
1090+++ src/framework/Internal/RandomGenerator.cs 2013-05-03 03:03:44 +0000
1091@@ -0,0 +1,184 @@
1092+using System;
1093+using System.Collections.Generic;
1094+using System.Reflection;
1095+
1096+namespace NUnit.Framework.Internal
1097+{
1098+ /// <summary>
1099+ /// This is a wrapper class for Random.
1100+ /// Additionaly functionality is built into this class to handle the following:
1101+ /// Random Int
1102+ /// Random Short
1103+ /// Random Bool
1104+ /// Random Float
1105+ /// Random Double
1106+ /// Random Enum
1107+ /// </summary>
1108+ public class RandomGenerator
1109+ {
1110+ #region Members & Constructor
1111+ /// <summary>
1112+ /// Seed for the wrapped Random
1113+ /// </summary>
1114+ public readonly int seed;
1115+
1116+ private Random random;
1117+
1118+ /// <summary>
1119+ /// Lazy-loaded Random built on the readonly Seed
1120+ /// </summary>
1121+ private Random Rand
1122+ {
1123+ get
1124+ {
1125+ random = random == null ? new Random(seed) : random;
1126+ return random;
1127+ }
1128+ }
1129+
1130+ /// <summary>
1131+ /// Constructor requires Seed value in order to store it for use in Random creation
1132+ /// </summary>
1133+ /// <param name="seed"></param>
1134+ public RandomGenerator(int seed)
1135+ {
1136+ this.seed = seed;
1137+ }
1138+ #endregion
1139+
1140+ #region Ints
1141+ /// <summary>
1142+ /// Get Next Integer from Random
1143+ /// </summary>
1144+ /// <returns> int </returns>
1145+ public int GetInt()
1146+ {
1147+ return Rand.Next();
1148+ }
1149+ /// <summary>
1150+ /// Get Next Integer within the specified min & max from Random
1151+ /// </summary>
1152+ /// <param name="min"></param>
1153+ /// <param name="max"></param>
1154+ /// <returns> int </returns>
1155+ public int GetInt(int min, int max)
1156+ {
1157+ return Rand.Next(min, max);
1158+ }
1159+ #endregion
1160+
1161+ #region Shorts
1162+ /// <summary>
1163+ /// Get Next Short from Random
1164+ /// </summary>
1165+ /// <returns> short </returns>
1166+ public short GetShort()
1167+ {
1168+ return (short)Rand.Next(short.MinValue, short.MaxValue);
1169+ }
1170+ /// <summary>
1171+ /// Get Next Short within the specified min & max from Random
1172+ /// </summary>
1173+ /// <param name="min"></param>
1174+ /// <param name="max"></param>
1175+ /// <returns> short </returns>
1176+ public short GetShort(short min, short max)
1177+ {
1178+ return (short)Rand.Next(min, max);
1179+ }
1180+ #endregion
1181+
1182+ #region Bytes
1183+ /// <summary>
1184+ /// Get Next Byte from Random
1185+ /// </summary>
1186+ /// <returns> byte </returns>
1187+ public byte GetByte()
1188+ {
1189+ return (byte)Rand.Next(Byte.MinValue, Byte.MaxValue);
1190+ }
1191+ /// <summary>
1192+ /// Get Next Byte within the specified min & max from Random
1193+ /// </summary>
1194+ /// <param name="min"></param>
1195+ /// <param name="max"></param>
1196+ /// <returns> byte </returns>
1197+ public byte GetByte(byte min, byte max)
1198+ {
1199+ return (byte)Rand.Next(min, max);
1200+ }
1201+ #endregion
1202+
1203+ #region Bools
1204+ /// <summary>
1205+ /// Get Random Boolean value
1206+ /// </summary>
1207+ /// <returns> bool </returns>
1208+ public bool GetBool()
1209+ {
1210+ return Rand.Next(0, 1) == 0;
1211+ }
1212+ /// <summary>
1213+ /// Get Random Boolean value based on the probability of that value being true
1214+ /// </summary>
1215+ /// <param name="probability"></param>
1216+ /// <returns> bool </returns>
1217+ public bool GetBool(double probability)
1218+ {
1219+ return Rand.NextDouble() < Math.Abs(probability % 1.0);
1220+ }
1221+ #endregion
1222+
1223+ #region Double & Float
1224+ /// <summary>
1225+ /// Get Next Double from Random
1226+ /// </summary>
1227+ /// <returns></returns>
1228+ public double GetDouble()
1229+ {
1230+ return Rand.NextDouble();
1231+ }
1232+ /// <summary>
1233+ /// Get Next Float from Random
1234+ /// </summary>
1235+ /// <returns></returns>
1236+ public float GetFloat()
1237+ {
1238+ return (float)Rand.NextDouble();
1239+ }
1240+ #endregion
1241+
1242+ #region Enums
1243+#if SILVERLIGHT || NETCF
1244+ /// <summary>
1245+ /// Return a random enum value from the specified type
1246+ /// </summary>
1247+ /// <param name="enumType"></param>
1248+ /// <returns> object </returns>
1249+ public object GetEnum(Type enumType)
1250+ {
1251+ List<string> enumNames = new List<string>();
1252+ foreach (FieldInfo fi in enumType.GetType().GetFields(BindingFlags.Static | BindingFlags.Public)){
1253+ enumNames.Add(fi.Name);
1254+ }
1255+ string enumeration = enumNames[Rand.Next(0, enumNames.Count)];
1256+ return Enum.Parse(enumType, enumeration, true);
1257+ }
1258+
1259+#else
1260+ /// <summary>
1261+ /// Return a random enum value representation of the specified Type
1262+ /// </summary>
1263+ /// <typeparam name="T"></typeparam>
1264+ /// <returns> T </returns>
1265+ public T GetEnum<T>()
1266+ {
1267+ string[] items = Enum.GetNames(typeof(T));
1268+ string enumeration = items[Rand.Next(0, items.Length)];
1269+ return (T)Enum.Parse(typeof(T), enumeration, true);
1270+ }
1271+#endif
1272+ #endregion
1273+
1274+ }
1275+}
1276
1277=== modified file 'src/framework/Internal/TestExecutionContext.cs'
1278--- src/framework/Internal/TestExecutionContext.cs 2012-12-25 00:26:29 +0000
1279+++ src/framework/Internal/TestExecutionContext.cs 2013-05-03 03:03:44 +0000
1280@@ -1,608 +1,625 @@
1281-// ***********************************************************************
1282-// Copyright (c) 2011 Charlie Poole
1283-//
1284-// Permission is hereby granted, free of charge, to any person obtaining
1285-// a copy of this software and associated documentation files (the
1286-// "Software"), to deal in the Software without restriction, including
1287-// without limitation the rights to use, copy, modify, merge, publish,
1288-// distribute, sublicense, and/or sell copies of the Software, and to
1289-// permit persons to whom the Software is furnished to do so, subject to
1290-// the following conditions:
1291-//
1292-// The above copyright notice and this permission notice shall be
1293-// included in all copies or substantial portions of the Software.
1294-//
1295-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1296-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1297-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1298-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1299-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1300-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1301-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1302-// ***********************************************************************
1303-
1304-using System;
1305-using System.Collections;
1306-using System.Collections.Specialized;
1307-using System.IO;
1308-using System.Diagnostics;
1309-using System.Globalization;
1310-using System.Threading;
1311-
1312-#if !NUNITLITE
1313-using System.Security.Principal;
1314-#endif
1315-
1316-using NUnit.Framework.Api;
1317-#if !NETCF
1318-using System.Runtime.Remoting.Messaging;
1319-#endif
1320-
1321-namespace NUnit.Framework.Internal
1322-{
1323- /// <summary>
1324- /// Helper class used to save and restore certain static or
1325- /// singleton settings in the environment that affect tests
1326- /// or which might be changed by the user tests.
1327- ///
1328- /// An internal class is used to hold settings and a stack
1329- /// of these objects is pushed and popped as Save and Restore
1330- /// are called.
1331- ///
1332- /// Static methods for each setting forward to the internal
1333- /// object on the top of the stack.
1334- /// </summary>
1335- public class TestExecutionContext
1336-#if !SILVERLIGHT && !NETCF
1337- : ILogicalThreadAffinative
1338-#endif
1339- {
1340- #region Instance Fields
1341-
1342- /// <summary>
1343- /// Link to a prior saved context
1344- /// </summary>
1345- public TestExecutionContext prior;
1346-
1347- /// <summary>
1348- /// The currently executing test
1349- /// </summary>
1350- private Test currentTest;
1351-
1352- /// <summary>
1353- /// The time the test began execution
1354- /// </summary>
1355- private DateTime startTime;
1356-
1357- /// <summary>
1358- /// The active TestResult for the current test
1359- /// </summary>
1360- private TestResult currentResult;
1361-
1362- /// <summary>
1363- /// The work directory to receive test output
1364- /// </summary>
1365- private string workDirectory;
1366-
1367- /// <summary>
1368- /// The object on which tests are currently being executed - i.e. the user fixture object
1369- /// </summary>
1370- private object testObject;
1371-
1372- /// <summary>
1373- /// The event listener currently receiving notifications
1374- /// </summary>
1375- private ITestListener listener = TestListener.NULL;
1376-
1377- /// <summary>
1378- /// The number of assertions for the current test
1379- /// </summary>
1380- private int assertCount;
1381-
1382- /// <summary>
1383- /// Indicates whether execution should terminate after the first error
1384- /// </summary>
1385- private bool stopOnError;
1386-
1387- /// <summary>
1388- /// Default timeout for test cases
1389- /// </summary>
1390- private int testCaseTimeout;
1391-
1392-#if !NETCF
1393- /// <summary>
1394- /// The current culture
1395- /// </summary>
1396- private CultureInfo currentCulture;
1397-
1398- /// <summary>
1399- /// The current UI culture
1400- /// </summary>
1401- private CultureInfo currentUICulture;
1402-#endif
1403-
1404-#if !NETCF && !SILVERLIGHT
1405- /// <summary>
1406- /// Destination for standard output
1407- /// </summary>
1408- private TextWriter outWriter;
1409-
1410- /// <summary>
1411- /// Destination for standard error
1412- /// </summary>
1413- private TextWriter errorWriter;
1414-
1415- /// <summary>
1416- /// Indicates whether trace is enabled
1417- /// </summary>
1418- private bool tracing;
1419-
1420- /// <summary>
1421- /// Destination for Trace output
1422- /// </summary>
1423- private TextWriter traceWriter;
1424-#endif
1425-
1426-#if !NUNITLITE
1427- /// <summary>
1428- /// Indicates whether logging is enabled
1429- /// </summary>
1430- private bool logging;
1431-
1432- /// <summary>
1433- /// The current working directory
1434- /// </summary>
1435- private string currentDirectory;
1436-
1437- private Log4NetCapture logCapture;
1438-
1439- /// <summary>
1440- /// The current Principal.
1441- /// </summary>
1442- private IPrincipal currentPrincipal;
1443-#endif
1444-
1445- #endregion
1446-
1447- #region Constructors
1448-
1449- /// <summary>
1450- /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
1451- /// </summary>
1452- public TestExecutionContext()
1453- {
1454- this.prior = null;
1455- this.testCaseTimeout = 0;
1456-
1457-#if !NETCF
1458- this.currentCulture = CultureInfo.CurrentCulture;
1459- this.currentUICulture = CultureInfo.CurrentUICulture;
1460-#endif
1461-
1462-#if !NETCF && !SILVERLIGHT
1463- this.outWriter = Console.Out;
1464- this.errorWriter = Console.Error;
1465- this.traceWriter = null;
1466- this.tracing = false;
1467-#endif
1468-
1469-#if !NUNITLITE
1470- this.logging = false;
1471- this.currentDirectory = Environment.CurrentDirectory;
1472- this.logCapture = new Log4NetCapture();
1473- this.currentPrincipal = Thread.CurrentPrincipal;
1474-#endif
1475- }
1476-
1477- /// <summary>
1478- /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
1479- /// </summary>
1480- /// <param name="other">An existing instance of TestExecutionContext.</param>
1481- public TestExecutionContext( TestExecutionContext other )
1482- {
1483- this.prior = other;
1484-
1485- this.currentTest = other.currentTest;
1486- this.currentResult = other.currentResult;
1487- this.testObject = other.testObject;
1488- this.workDirectory = other.workDirectory;
1489- this.listener = other.listener;
1490- this.stopOnError = other.stopOnError;
1491- this.testCaseTimeout = other.testCaseTimeout;
1492-
1493-#if !NETCF
1494- this.currentCulture = CultureInfo.CurrentCulture;
1495- this.currentUICulture = CultureInfo.CurrentUICulture;
1496-#endif
1497-
1498-#if !NETCF && !SILVERLIGHT
1499- this.outWriter = other.outWriter;
1500- this.errorWriter = other.errorWriter;
1501- this.traceWriter = other.traceWriter;
1502- this.tracing = other.tracing;
1503-#endif
1504-
1505-#if !NUNITLITE
1506- this.logging = other.logging;
1507- this.currentDirectory = Environment.CurrentDirectory;
1508- this.logCapture = other.logCapture;
1509- this.currentPrincipal = Thread.CurrentPrincipal;
1510-#endif
1511- }
1512-
1513- #endregion
1514-
1515- #region Static Singleton Instance
1516-
1517- /// <summary>
1518- /// The current context, head of the list of saved contexts.
1519- /// </summary>
1520-#if SILVERLIGHT || NETCF
1521-#if (CLR_2_0 || CLR_4_0) && !NETCF
1522- [ThreadStatic]
1523-#endif
1524- private static TestExecutionContext current;
1525-#endif
1526-
1527- /// <summary>
1528- /// Gets the current context.
1529- /// </summary>
1530- /// <value>The current context.</value>
1531- public static TestExecutionContext CurrentContext
1532- {
1533- get
1534- {
1535-#if SILVERLIGHT || NETCF
1536- if (current == null)
1537- current = new TestExecutionContext();
1538-
1539- return current;
1540-#else
1541- return CallContext.GetData("NUnit.Framework.TestContext") as TestExecutionContext;
1542-#endif
1543- }
1544- }
1545-
1546- #endregion
1547-
1548- #region Static Methods
1549-
1550- internal static void SetCurrentContext(TestExecutionContext ec)
1551- {
1552-#if SILVERLIGHT || NETCF
1553- current = ec;
1554-#else
1555- CallContext.SetData("NUnit.Framework.TestContext", ec);
1556-#endif
1557- }
1558-
1559- #endregion
1560-
1561- #region Properties
1562-
1563- /// <summary>
1564- /// Gets or sets the current test
1565- /// </summary>
1566- public Test CurrentTest
1567- {
1568- get { return currentTest; }
1569- set { currentTest = value; }
1570- }
1571-
1572- /// <summary>
1573- /// The time the current test started execution
1574- /// </summary>
1575- public DateTime StartTime
1576- {
1577- get { return startTime; }
1578- set { startTime = value; }
1579- }
1580-
1581- /// <summary>
1582- /// Gets or sets the current test result
1583- /// </summary>
1584- public TestResult CurrentResult
1585- {
1586- get { return currentResult; }
1587- set { currentResult = value; }
1588- }
1589-
1590- /// <summary>
1591- /// The current test object - that is the user fixture
1592- /// object on which tests are being executed.
1593- /// </summary>
1594- public object TestObject
1595- {
1596- get { return testObject; }
1597- set { testObject = value; }
1598- }
1599-
1600- /// <summary>
1601- /// Get or set the working directory
1602- /// </summary>
1603- public string WorkDirectory
1604- {
1605- get { return workDirectory; }
1606- set { workDirectory = value; }
1607- }
1608-
1609- /// <summary>
1610- /// Get or set indicator that run should stop on the first error
1611- /// </summary>
1612- public bool StopOnError
1613- {
1614- get { return stopOnError; }
1615- set { stopOnError = value; }
1616- }
1617-
1618- /// <summary>
1619- /// The current test event listener
1620- /// </summary>
1621- internal ITestListener Listener
1622- {
1623- get { return listener; }
1624- set { listener = value; }
1625- }
1626-
1627- /// <summary>
1628- /// Gets the assert count.
1629- /// </summary>
1630- /// <value>The assert count.</value>
1631- internal int AssertCount
1632- {
1633- get { return assertCount; }
1634- set { assertCount = value; }
1635- }
1636-
1637- /// <summary>
1638- /// Gets or sets the test case timeout vaue
1639- /// </summary>
1640- public int TestCaseTimeout
1641- {
1642- get { return testCaseTimeout; }
1643- set { testCaseTimeout = value; }
1644- }
1645-
1646-#if !NETCF
1647- /// <summary>
1648- /// Saves or restores the CurrentCulture
1649- /// </summary>
1650- public CultureInfo CurrentCulture
1651- {
1652- get { return currentCulture; }
1653- set
1654- {
1655- currentCulture = value;
1656- Thread.CurrentThread.CurrentCulture = currentCulture;
1657- }
1658- }
1659-
1660- /// <summary>
1661- /// Saves or restores the CurrentUICulture
1662- /// </summary>
1663- public CultureInfo CurrentUICulture
1664- {
1665- get { return currentUICulture; }
1666- set
1667- {
1668- currentUICulture = value;
1669- Thread.CurrentThread.CurrentUICulture = currentUICulture;
1670- }
1671- }
1672-#endif
1673-
1674-#if !NETCF && !SILVERLIGHT
1675- /// <summary>
1676- /// Controls where Console.Out is directed
1677- /// </summary>
1678- internal TextWriter Out
1679- {
1680- get { return outWriter; }
1681- set
1682- {
1683- if ( outWriter != value )
1684- {
1685- outWriter = value;
1686- Console.Out.Flush();
1687- Console.SetOut( outWriter );
1688- }
1689- }
1690- }
1691-
1692- /// <summary>
1693- /// Controls where Console.Error is directed
1694- /// </summary>
1695- internal TextWriter Error
1696- {
1697- get { return errorWriter; }
1698- set
1699- {
1700- if ( errorWriter != value )
1701- {
1702- errorWriter = value;
1703- Console.Error.Flush();
1704- Console.SetError( errorWriter );
1705- }
1706- }
1707- }
1708-
1709- /// <summary>
1710- /// Controls whether trace and debug output are written
1711- /// to the standard output.
1712- /// </summary>
1713- internal bool Tracing
1714- {
1715- get { return tracing; }
1716- set
1717- {
1718- if (tracing != value)
1719+// ***********************************************************************
1720+// Copyright (c) 2011 Charlie Poole
1721+//
1722+// Permission is hereby granted, free of charge, to any person obtaining
1723+// a copy of this software and associated documentation files (the
1724+// "Software"), to deal in the Software without restriction, including
1725+// without limitation the rights to use, copy, modify, merge, publish,
1726+// distribute, sublicense, and/or sell copies of the Software, and to
1727+// permit persons to whom the Software is furnished to do so, subject to
1728+// the following conditions:
1729+//
1730+// The above copyright notice and this permission notice shall be
1731+// included in all copies or substantial portions of the Software.
1732+//
1733+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1734+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1735+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1736+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1737+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1738+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1739+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1740+// ***********************************************************************
1741+
1742+using System;
1743+using System.Collections;
1744+using System.Collections.Specialized;
1745+using System.IO;
1746+using System.Diagnostics;
1747+using System.Globalization;
1748+using System.Threading;
1749+
1750+#if !NUNITLITE
1751+using System.Security.Principal;
1752+#endif
1753+
1754+using NUnit.Framework.Api;
1755+#if !NETCF
1756+using System.Runtime.Remoting.Messaging;
1757+#endif
1758+
1759+namespace NUnit.Framework.Internal
1760+{
1761+ /// <summary>
1762+ /// Helper class used to save and restore certain static or
1763+ /// singleton settings in the environment that affect tests
1764+ /// or which might be changed by the user tests.
1765+ ///
1766+ /// An internal class is used to hold settings and a stack
1767+ /// of these objects is pushed and popped as Save and Restore
1768+ /// are called.
1769+ ///
1770+ /// Static methods for each setting forward to the internal
1771+ /// object on the top of the stack.
1772+ /// </summary>
1773+ public class TestExecutionContext
1774+#if !SILVERLIGHT && !NETCF
1775+ : ILogicalThreadAffinative
1776+#endif
1777+ {
1778+ #region Instance Fields
1779+
1780+ /// <summary>
1781+ /// Link to a prior saved context
1782+ /// </summary>
1783+ public TestExecutionContext prior;
1784+
1785+ /// <summary>
1786+ /// The currently executing test
1787+ /// </summary>
1788+ private Test currentTest;
1789+
1790+ /// <summary>
1791+ /// The time the test began execution
1792+ /// </summary>
1793+ private DateTime startTime;
1794+
1795+ /// <summary>
1796+ /// The active TestResult for the current test
1797+ /// </summary>
1798+ private TestResult currentResult;
1799+
1800+ /// <summary>
1801+ /// The work directory to receive test output
1802+ /// </summary>
1803+ private string workDirectory;
1804+
1805+ /// <summary>
1806+ /// The object on which tests are currently being executed - i.e. the user fixture object
1807+ /// </summary>
1808+ private object testObject;
1809+
1810+ /// <summary>
1811+ /// The event listener currently receiving notifications
1812+ /// </summary>
1813+ private ITestListener listener = TestListener.NULL;
1814+
1815+ /// <summary>
1816+ /// The number of assertions for the current test
1817+ /// </summary>
1818+ private int assertCount;
1819+
1820+ /// <summary>
1821+ /// Indicates whether execution should terminate after the first error
1822+ /// </summary>
1823+ private bool stopOnError;
1824+
1825+ /// <summary>
1826+ /// Default timeout for test cases
1827+ /// </summary>
1828+ private int testCaseTimeout;
1829+
1830+ private RandomGenerator random;
1831+
1832+#if !NETCF
1833+ /// <summary>
1834+ /// The current culture
1835+ /// </summary>
1836+ private CultureInfo currentCulture;
1837+
1838+ /// <summary>
1839+ /// The current UI culture
1840+ /// </summary>
1841+ private CultureInfo currentUICulture;
1842+#endif
1843+
1844+#if !NETCF && !SILVERLIGHT
1845+ /// <summary>
1846+ /// Destination for standard output
1847+ /// </summary>
1848+ private TextWriter outWriter;
1849+
1850+ /// <summary>
1851+ /// Destination for standard error
1852+ /// </summary>
1853+ private TextWriter errorWriter;
1854+
1855+ /// <summary>
1856+ /// Indicates whether trace is enabled
1857+ /// </summary>
1858+ private bool tracing;
1859+
1860+ /// <summary>
1861+ /// Destination for Trace output
1862+ /// </summary>
1863+ private TextWriter traceWriter;
1864+#endif
1865+
1866+#if !NUNITLITE
1867+ /// <summary>
1868+ /// Indicates whether logging is enabled
1869+ /// </summary>
1870+ private bool logging;
1871+
1872+ /// <summary>
1873+ /// The current working directory
1874+ /// </summary>
1875+ private string currentDirectory;
1876+
1877+ private Log4NetCapture logCapture;
1878+
1879+ /// <summary>
1880+ /// The current Principal.
1881+ /// </summary>
1882+ private IPrincipal currentPrincipal;
1883+#endif
1884+
1885+ #endregion
1886+
1887+ #region Constructors
1888+
1889+ /// <summary>
1890+ /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
1891+ /// </summary>
1892+ public TestExecutionContext()
1893+ {
1894+ this.prior = null;
1895+ this.testCaseTimeout = 0;
1896+
1897+#if !NETCF
1898+ this.currentCulture = CultureInfo.CurrentCulture;
1899+ this.currentUICulture = CultureInfo.CurrentUICulture;
1900+#endif
1901+
1902+#if !NETCF && !SILVERLIGHT
1903+ this.outWriter = Console.Out;
1904+ this.errorWriter = Console.Error;
1905+ this.traceWriter = null;
1906+ this.tracing = false;
1907+#endif
1908+
1909+#if !NUNITLITE
1910+ this.logging = false;
1911+ this.currentDirectory = Environment.CurrentDirectory;
1912+ this.logCapture = new Log4NetCapture();
1913+ this.currentPrincipal = Thread.CurrentPrincipal;
1914+#endif
1915+ }
1916+
1917+ /// <summary>
1918+ /// Initializes a new instance of the <see cref="TestExecutionContext"/> class.
1919+ /// </summary>
1920+ /// <param name="other">An existing instance of TestExecutionContext.</param>
1921+ public TestExecutionContext( TestExecutionContext other )
1922+ {
1923+ this.prior = other;
1924+
1925+ this.currentTest = other.currentTest;
1926+ this.currentResult = other.currentResult;
1927+ this.testObject = other.testObject;
1928+ this.workDirectory = other.workDirectory;
1929+ this.listener = other.listener;
1930+ this.stopOnError = other.stopOnError;
1931+ this.testCaseTimeout = other.testCaseTimeout;
1932+
1933+#if !NETCF
1934+ this.currentCulture = CultureInfo.CurrentCulture;
1935+ this.currentUICulture = CultureInfo.CurrentUICulture;
1936+#endif
1937+
1938+#if !NETCF && !SILVERLIGHT
1939+ this.outWriter = other.outWriter;
1940+ this.errorWriter = other.errorWriter;
1941+ this.traceWriter = other.traceWriter;
1942+ this.tracing = other.tracing;
1943+#endif
1944+
1945+#if !NUNITLITE
1946+ this.logging = other.logging;
1947+ this.currentDirectory = Environment.CurrentDirectory;
1948+ this.logCapture = other.logCapture;
1949+ this.currentPrincipal = Thread.CurrentPrincipal;
1950+#endif
1951+ }
1952+
1953+ #endregion
1954+
1955+ #region Static Singleton Instance
1956+
1957+ /// <summary>
1958+ /// The current context, head of the list of saved contexts.
1959+ /// </summary>
1960+#if SILVERLIGHT || NETCF
1961+#if (CLR_2_0 || CLR_4_0) && !NETCF
1962+ [ThreadStatic]
1963+#endif
1964+ private static TestExecutionContext current;
1965+#endif
1966+
1967+ /// <summary>
1968+ /// Gets the current context.
1969+ /// </summary>
1970+ /// <value>The current context.</value>
1971+ public static TestExecutionContext CurrentContext
1972+ {
1973+ get
1974+ {
1975+#if SILVERLIGHT || NETCF
1976+ if (current == null)
1977+ current = new TestExecutionContext();
1978+
1979+ return current;
1980+#else
1981+ return CallContext.GetData("NUnit.Framework.TestContext") as TestExecutionContext;
1982+#endif
1983+ }
1984+ }
1985+
1986+ #endregion
1987+
1988+ #region Static Methods
1989+
1990+ internal static void SetCurrentContext(TestExecutionContext ec)
1991+ {
1992+#if SILVERLIGHT || NETCF
1993+ current = ec;
1994+#else
1995+ CallContext.SetData("NUnit.Framework.TestContext", ec);
1996+#endif
1997+ }
1998+
1999+ #endregion
2000+
2001+ #region Properties
2002+
2003+ /// <summary>
2004+ /// Gets or sets the current test
2005+ /// </summary>
2006+ public Test CurrentTest
2007+ {
2008+ get { return currentTest; }
2009+ set { currentTest = value; }
2010+ }
2011+
2012+ /// <summary>
2013+ /// The time the current test started execution
2014+ /// </summary>
2015+ public DateTime StartTime
2016+ {
2017+ get { return startTime; }
2018+ set { startTime = value; }
2019+ }
2020+
2021+ /// <summary>
2022+ /// Gets or sets the current test result
2023+ /// </summary>
2024+ public TestResult CurrentResult
2025+ {
2026+ get { return currentResult; }
2027+ set { currentResult = value; }
2028+ }
2029+
2030+ /// <summary>
2031+ /// The current test object - that is the user fixture
2032+ /// object on which tests are being executed.
2033+ /// </summary>
2034+ public object TestObject
2035+ {
2036+ get { return testObject; }
2037+ set { testObject = value; }
2038+ }
2039+
2040+ /// <summary>
2041+ /// Get or set the working directory
2042+ /// </summary>
2043+ public string WorkDirectory
2044+ {
2045+ get { return workDirectory; }
2046+ set { workDirectory = value; }
2047+ }
2048+
2049+ /// <summary>
2050+ /// Get or set indicator that run should stop on the first error
2051+ /// </summary>
2052+ public bool StopOnError
2053+ {
2054+ get { return stopOnError; }
2055+ set { stopOnError = value; }
2056+ }
2057+
2058+ /// <summary>
2059+ /// The current test event listener
2060+ /// </summary>
2061+ internal ITestListener Listener
2062+ {
2063+ get { return listener; }
2064+ set { listener = value; }
2065+ }
2066+
2067+ /// <summary>
2068+ /// Gets the RandomGenerator specific to this Test
2069+ /// </summary>
2070+ public RandomGenerator Random
2071+ {
2072+ get
2073+ {
2074+ if (random == null)
2075 {
2076- if (traceWriter != null && tracing)
2077- StopTracing();
2078-
2079- tracing = value;
2080-
2081- if (traceWriter != null && tracing)
2082- StartTracing();
2083+ random = new RandomGenerator(currentTest.Seed);
2084 }
2085- }
2086- }
2087-
2088- /// <summary>
2089- /// Controls where Trace output is directed
2090- /// </summary>
2091- internal TextWriter TraceWriter
2092- {
2093- get { return traceWriter; }
2094- set
2095- {
2096- if ( traceWriter != value )
2097- {
2098- if ( traceWriter != null && tracing )
2099- StopTracing();
2100-
2101- traceWriter = value;
2102-
2103- if ( traceWriter != null && tracing )
2104- StartTracing();
2105- }
2106- }
2107- }
2108-
2109- private void StopTracing()
2110- {
2111- traceWriter.Close();
2112- System.Diagnostics.Trace.Listeners.Remove( "NUnit" );
2113- }
2114-
2115- private void StartTracing()
2116- {
2117- System.Diagnostics.Trace.Listeners.Add( new TextWriterTraceListener( traceWriter, "NUnit" ) );
2118- }
2119-#endif
2120-
2121-#if !NUNITLITE
2122- /// <summary>
2123- /// Controls whether log output is captured
2124- /// </summary>
2125- public bool Logging
2126- {
2127- get { return logCapture.Enabled; }
2128- set { logCapture.Enabled = value; }
2129- }
2130-
2131- /// <summary>
2132- /// Gets or sets the Log writer, which is actually held by a log4net
2133- /// TextWriterAppender. When first set, the appender will be created
2134- /// and will thereafter send any log events to the writer.
2135- ///
2136- /// In normal operation, LogWriter is set to an EventListenerTextWriter
2137- /// connected to the EventQueue in the test domain. The events are
2138- /// subsequently captured in the Gui an the output displayed in
2139- /// the Log tab. The application under test does not need to define
2140- /// any additional appenders.
2141- /// </summary>
2142- public TextWriter LogWriter
2143- {
2144- get { return logCapture.Writer; }
2145- set { logCapture.Writer = value; }
2146- }
2147-
2148- /// <summary>
2149- /// Saves and restores the CurrentDirectory
2150- /// </summary>
2151- public string CurrentDirectory
2152- {
2153- get { return currentDirectory; }
2154- set
2155- {
2156- currentDirectory = value;
2157- Environment.CurrentDirectory = currentDirectory;
2158- }
2159- }
2160-
2161- /// <summary>
2162- /// Gets or sets the current <see cref="IPrincipal"/> for the Thread.
2163- /// </summary>
2164- public IPrincipal CurrentPrincipal
2165- {
2166- get { return this.currentPrincipal; }
2167- set
2168- {
2169- this.currentPrincipal = value;
2170- Thread.CurrentPrincipal = this.currentPrincipal;
2171- }
2172- }
2173-#endif
2174-
2175- #endregion
2176-
2177- #region Instance Methods
2178-
2179- /// <summary>
2180- /// Saves the old context and returns a fresh one
2181- /// with the same settings.
2182- /// </summary>
2183- public TestExecutionContext Save()
2184- {
2185- return new TestExecutionContext(this);
2186- }
2187-
2188- /// <summary>
2189- /// Restores the last saved context and puts
2190- /// any saved settings back into effect.
2191- /// </summary>
2192- public TestExecutionContext Restore()
2193- {
2194- if (prior == null)
2195- throw new InvalidOperationException("TestContext: too many Restores");
2196-
2197- this.TestCaseTimeout = prior.TestCaseTimeout;
2198-
2199-#if !NETCF
2200- this.CurrentCulture = prior.CurrentCulture;
2201- this.CurrentUICulture = prior.CurrentUICulture;
2202-#endif
2203-
2204-#if !NETCF && !SILVERLIGHT
2205- this.Out = prior.Out;
2206- this.Error = prior.Error;
2207- this.Tracing = prior.Tracing;
2208-#endif
2209-
2210-#if !NUNITLITE
2211- this.CurrentDirectory = prior.CurrentDirectory;
2212- this.CurrentPrincipal = prior.CurrentPrincipal;
2213-#endif
2214-
2215- return prior;
2216- }
2217-
2218- /// <summary>
2219- /// Record any changes in the environment made by
2220- /// the test code in the execution context so it
2221- /// will be passed on to lower level tests.
2222- /// </summary>
2223- public void UpdateContext()
2224- {
2225-#if !NETCF
2226- this.currentCulture = CultureInfo.CurrentCulture;
2227- this.currentUICulture = CultureInfo.CurrentUICulture;
2228-#endif
2229-#if !NUNITLITE
2230- this.currentDirectory = Environment.CurrentDirectory;
2231- this.currentPrincipal = System.Threading.Thread.CurrentPrincipal;
2232-#endif
2233- }
2234-
2235- /// <summary>
2236- /// Increments the assert count.
2237- /// </summary>
2238- public void IncrementAssertCount()
2239- {
2240- System.Threading.Interlocked.Increment(ref assertCount);
2241- }
2242-
2243- #endregion
2244+ return random;
2245+ }
2246+ }
2247+
2248+ /// <summary>
2249+ /// Gets the assert count.
2250+ /// </summary>
2251+ /// <value>The assert count.</value>
2252+ internal int AssertCount
2253+ {
2254+ get { return assertCount; }
2255+ set { assertCount = value; }
2256+ }
2257+
2258+ /// <summary>
2259+ /// Gets or sets the test case timeout vaue
2260+ /// </summary>
2261+ public int TestCaseTimeout
2262+ {
2263+ get { return testCaseTimeout; }
2264+ set { testCaseTimeout = value; }
2265+ }
2266+
2267+#if !NETCF
2268+ /// <summary>
2269+ /// Saves or restores the CurrentCulture
2270+ /// </summary>
2271+ public CultureInfo CurrentCulture
2272+ {
2273+ get { return currentCulture; }
2274+ set
2275+ {
2276+ currentCulture = value;
2277+ Thread.CurrentThread.CurrentCulture = currentCulture;
2278+ }
2279+ }
2280+
2281+ /// <summary>
2282+ /// Saves or restores the CurrentUICulture
2283+ /// </summary>
2284+ public CultureInfo CurrentUICulture
2285+ {
2286+ get { return currentUICulture; }
2287+ set
2288+ {
2289+ currentUICulture = value;
2290+ Thread.CurrentThread.CurrentUICulture = currentUICulture;
2291+ }
2292+ }
2293+#endif
2294+
2295+#if !NETCF && !SILVERLIGHT
2296+ /// <summary>
2297+ /// Controls where Console.Out is directed
2298+ /// </summary>
2299+ internal TextWriter Out
2300+ {
2301+ get { return outWriter; }
2302+ set
2303+ {
2304+ if ( outWriter != value )
2305+ {
2306+ outWriter = value;
2307+ Console.Out.Flush();
2308+ Console.SetOut( outWriter );
2309+ }
2310+ }
2311+ }
2312+
2313+ /// <summary>
2314+ /// Controls where Console.Error is directed
2315+ /// </summary>
2316+ internal TextWriter Error
2317+ {
2318+ get { return errorWriter; }
2319+ set
2320+ {
2321+ if ( errorWriter != value )
2322+ {
2323+ errorWriter = value;
2324+ Console.Error.Flush();
2325+ Console.SetError( errorWriter );
2326+ }
2327+ }
2328+ }
2329+
2330+ /// <summary>
2331+ /// Controls whether trace and debug output are written
2332+ /// to the standard output.
2333+ /// </summary>
2334+ internal bool Tracing
2335+ {
2336+ get { return tracing; }
2337+ set
2338+ {
2339+ if (tracing != value)
2340+ {
2341+ if (traceWriter != null && tracing)
2342+ StopTracing();
2343+
2344+ tracing = value;
2345+
2346+ if (traceWriter != null && tracing)
2347+ StartTracing();
2348+ }
2349+ }
2350+ }
2351+
2352+ /// <summary>
2353+ /// Controls where Trace output is directed
2354+ /// </summary>
2355+ internal TextWriter TraceWriter
2356+ {
2357+ get { return traceWriter; }
2358+ set
2359+ {
2360+ if ( traceWriter != value )
2361+ {
2362+ if ( traceWriter != null && tracing )
2363+ StopTracing();
2364+
2365+ traceWriter = value;
2366+
2367+ if ( traceWriter != null && tracing )
2368+ StartTracing();
2369+ }
2370+ }
2371+ }
2372+
2373+ private void StopTracing()
2374+ {
2375+ traceWriter.Close();
2376+ System.Diagnostics.Trace.Listeners.Remove( "NUnit" );
2377+ }
2378+
2379+ private void StartTracing()
2380+ {
2381+ System.Diagnostics.Trace.Listeners.Add( new TextWriterTraceListener( traceWriter, "NUnit" ) );
2382+ }
2383+#endif
2384+
2385+#if !NUNITLITE
2386+ /// <summary>
2387+ /// Controls whether log output is captured
2388+ /// </summary>
2389+ public bool Logging
2390+ {
2391+ get { return logCapture.Enabled; }
2392+ set { logCapture.Enabled = value; }
2393+ }
2394+
2395+ /// <summary>
2396+ /// Gets or sets the Log writer, which is actually held by a log4net
2397+ /// TextWriterAppender. When first set, the appender will be created
2398+ /// and will thereafter send any log events to the writer.
2399+ ///
2400+ /// In normal operation, LogWriter is set to an EventListenerTextWriter
2401+ /// connected to the EventQueue in the test domain. The events are
2402+ /// subsequently captured in the Gui an the output displayed in
2403+ /// the Log tab. The application under test does not need to define
2404+ /// any additional appenders.
2405+ /// </summary>
2406+ public TextWriter LogWriter
2407+ {
2408+ get { return logCapture.Writer; }
2409+ set { logCapture.Writer = value; }
2410+ }
2411+
2412+ /// <summary>
2413+ /// Saves and restores the CurrentDirectory
2414+ /// </summary>
2415+ public string CurrentDirectory
2416+ {
2417+ get { return currentDirectory; }
2418+ set
2419+ {
2420+ currentDirectory = value;
2421+ Environment.CurrentDirectory = currentDirectory;
2422+ }
2423+ }
2424+
2425+ /// <summary>
2426+ /// Gets or sets the current <see cref="IPrincipal"/> for the Thread.
2427+ /// </summary>
2428+ public IPrincipal CurrentPrincipal
2429+ {
2430+ get { return this.currentPrincipal; }
2431+ set
2432+ {
2433+ this.currentPrincipal = value;
2434+ Thread.CurrentPrincipal = this.currentPrincipal;
2435+ }
2436+ }
2437+#endif
2438+
2439+ #endregion
2440+
2441+ #region Instance Methods
2442+
2443+ /// <summary>
2444+ /// Saves the old context and returns a fresh one
2445+ /// with the same settings.
2446+ /// </summary>
2447+ public TestExecutionContext Save()
2448+ {
2449+ return new TestExecutionContext(this);
2450+ }
2451+
2452+ /// <summary>
2453+ /// Restores the last saved context and puts
2454+ /// any saved settings back into effect.
2455+ /// </summary>
2456+ public TestExecutionContext Restore()
2457+ {
2458+ if (prior == null)
2459+ throw new InvalidOperationException("TestContext: too many Restores");
2460+
2461+ this.TestCaseTimeout = prior.TestCaseTimeout;
2462+
2463+#if !NETCF
2464+ this.CurrentCulture = prior.CurrentCulture;
2465+ this.CurrentUICulture = prior.CurrentUICulture;
2466+#endif
2467+
2468+#if !NETCF && !SILVERLIGHT
2469+ this.Out = prior.Out;
2470+ this.Error = prior.Error;
2471+ this.Tracing = prior.Tracing;
2472+#endif
2473+
2474+#if !NUNITLITE
2475+ this.CurrentDirectory = prior.CurrentDirectory;
2476+ this.CurrentPrincipal = prior.CurrentPrincipal;
2477+#endif
2478+
2479+ return prior;
2480+ }
2481+
2482+ /// <summary>
2483+ /// Record any changes in the environment made by
2484+ /// the test code in the execution context so it
2485+ /// will be passed on to lower level tests.
2486+ /// </summary>
2487+ public void UpdateContext()
2488+ {
2489+#if !NETCF
2490+ this.currentCulture = CultureInfo.CurrentCulture;
2491+ this.currentUICulture = CultureInfo.CurrentUICulture;
2492+#endif
2493+#if !NUNITLITE
2494+ this.currentDirectory = Environment.CurrentDirectory;
2495+ this.currentPrincipal = System.Threading.Thread.CurrentPrincipal;
2496+#endif
2497+ }
2498+
2499+ /// <summary>
2500+ /// Increments the assert count.
2501+ /// </summary>
2502+ public void IncrementAssertCount()
2503+ {
2504+ System.Threading.Interlocked.Increment(ref assertCount);
2505+ }
2506+
2507+ #endregion
2508 }
2509-}
2510+}
2511
2512=== modified file 'src/framework/Internal/TestFilter.cs'
2513--- src/framework/Internal/TestFilter.cs 2012-09-15 18:55:04 +0000
2514+++ src/framework/Internal/TestFilter.cs 2013-05-03 03:03:44 +0000
2515@@ -37,7 +37,15 @@
2516 /// <summary>
2517 /// Unique Empty filter.
2518 /// </summary>
2519- public static TestFilter Empty = new EmptyFilter();
2520+ public static TestFilter Empty = new EmptyFilter();
2521+
2522+ /// <summary>
2523+ /// Indicates whether this is the EmptyFilter
2524+ /// </summary>
2525+ public bool IsEmpty
2526+ {
2527+ get { return this is TestFilter.EmptyFilter; }
2528+ }
2529
2530 /// <summary>
2531 /// Determine if a particular test passes the filter criteria. The default
2532
2533=== modified file 'src/framework/Internal/Tests/Test.cs'
2534--- src/framework/Internal/Tests/Test.cs 2012-10-31 18:06:35 +0000
2535+++ src/framework/Internal/Tests/Test.cs 2013-05-03 03:03:44 +0000
2536@@ -1,404 +1,415 @@
2537-// ***********************************************************************
2538-// Copyright (c) 2012 Charlie Poole
2539-//
2540-// Permission is hereby granted, free of charge, to any person obtaining
2541-// a copy of this software and associated documentation files (the
2542-// "Software"), to deal in the Software without restriction, including
2543-// without limitation the rights to use, copy, modify, merge, publish,
2544-// distribute, sublicense, and/or sell copies of the Software, and to
2545-// permit persons to whom the Software is furnished to do so, subject to
2546-// the following conditions:
2547-//
2548-// The above copyright notice and this permission notice shall be
2549-// included in all copies or substantial portions of the Software.
2550-//
2551-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2552-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2553-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2554-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2555-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2556-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2557-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2558-// ***********************************************************************
2559-
2560-using System;
2561-using System.Reflection;
2562-using NUnit.Framework.Api;
2563-using NUnit.Framework.Internal.Commands;
2564-using NUnit.Framework.Internal.WorkItems;
2565-
2566-namespace NUnit.Framework.Internal
2567-{
2568- /// <summary>
2569- /// The Test abstract class represents a test within the framework.
2570- /// </summary>
2571- public abstract class Test : ITest, IComparable
2572- {
2573- #region Fields
2574-
2575- /// <summary>
2576- /// Static value to seed ids. It's started at 1000 so any
2577- /// uninitialized ids will stand out.
2578- /// </summary>
2579- private static int nextID = 1000;
2580-
2581- private int id;
2582- private string name;
2583- private string fullName;
2584-
2585- /// <summary>
2586- /// Indicates whether the test should be executed
2587- /// </summary>
2588- private RunState runState;
2589-
2590- /// <summary>
2591- /// Test suite containing this test, or null
2592- /// </summary>
2593- private ITest parent;
2594-
2595- /// <summary>
2596- /// A dictionary of properties, used to add information
2597- /// to tests without requiring the class to change.
2598- /// </summary>
2599- private PropertyBag properties;
2600-
2601- /// <summary>
2602- /// The System.Type of the fixture for this test, if there is one
2603- /// </summary>
2604- private Type fixtureType;
2605-
2606- /// <summary>
2607- /// The fixture object, if it has been created
2608- /// </summary>
2609- private object fixture;
2610-
2611- /// <summary>
2612- /// The SetUp methods.
2613- /// </summary>
2614- protected MethodInfo[] setUpMethods;
2615-
2616- /// <summary>
2617- /// The teardown methods
2618- /// </summary>
2619- protected MethodInfo[] tearDownMethods;
2620-
2621- #endregion
2622-
2623- #region Construction
2624-
2625- /// <summary>
2626- /// Constructs a test given its name
2627- /// </summary>
2628- /// <param name="name">The name of the test</param>
2629- protected Test( string name )
2630- {
2631- this.fullName = name;
2632- this.name = name;
2633- this.id = unchecked(nextID++);
2634-
2635- this.runState = RunState.Runnable;
2636- }
2637-
2638- /// <summary>
2639- /// Constructs a test given the path through the
2640- /// test hierarchy to its parent and a name.
2641- /// </summary>
2642- /// <param name="pathName">The parent tests full name</param>
2643- /// <param name="name">The name of the test</param>
2644- protected Test( string pathName, string name )
2645- {
2646- this.fullName = pathName == null || pathName == string.Empty
2647- ? name : pathName + "." + name;
2648- this.name = name;
2649- this.id = unchecked(nextID++);
2650-
2651- this.runState = RunState.Runnable;
2652- }
2653-
2654- /// <summary>
2655- /// TODO: Documentation needed for constructor
2656- /// </summary>
2657- /// <param name="fixtureType"></param>
2658- protected Test(Type fixtureType) : this(fixtureType.FullName)
2659- {
2660- this.fixtureType = fixtureType;
2661- }
2662-
2663- #endregion
2664-
2665- #region ITest Members
2666-
2667- /// <summary>
2668- /// Gets or sets the id of the test
2669- /// </summary>
2670- /// <value></value>
2671- public int Id
2672- {
2673- get { return id; }
2674- set { id = value; }
2675- }
2676-
2677- /// <summary>
2678- /// Gets or sets the name of the test
2679- /// </summary>
2680- public string Name
2681- {
2682- get { return name; }
2683- set { name = value; }
2684- }
2685-
2686- /// <summary>
2687- /// Gets or sets the fully qualified name of the test
2688- /// </summary>
2689- /// <value></value>
2690- public string FullName
2691- {
2692- get { return fullName; }
2693- set { fullName = value; }
2694- }
2695-
2696- /// <summary>
2697- /// Gets the Type of the fixture used in running this test
2698- /// or null if no fixture type is associated with it.
2699- /// </summary>
2700- public Type FixtureType
2701- {
2702- get { return fixtureType; }
2703- }
2704-
2705- /// <summary>
2706- /// Whether or not the test should be run
2707- /// </summary>
2708- public RunState RunState
2709- {
2710- get { return runState; }
2711- set { runState = value; }
2712- }
2713-
2714- /// <summary>
2715- /// Gets the name used for the top-level element in the
2716- /// XML representation of this test
2717- /// </summary>
2718- public abstract string XmlElementName
2719- {
2720- get;
2721- }
2722-
2723- /// <summary>
2724- /// Gets a string representing the type of test. Used as an attribute
2725- /// value in the XML representation of a test and has no other
2726- /// function in the framework.
2727- /// </summary>
2728- public virtual string TestType
2729- {
2730- get { return this.GetType().Name; }
2731- }
2732-
2733- /// <summary>
2734- /// Gets a count of test cases represented by
2735- /// or contained under this test.
2736- /// </summary>
2737- public virtual int TestCaseCount
2738- {
2739- get { return 1; }
2740- }
2741-
2742- /// <summary>
2743- /// Gets the properties for this test
2744- /// </summary>
2745- public IPropertyBag Properties
2746- {
2747- get
2748- {
2749- if ( properties == null )
2750- properties = new PropertyBag();
2751-
2752- return properties;
2753- }
2754- }
2755-
2756- /// <summary>
2757- /// Gets a bool indicating whether the current test
2758- /// has any descendant tests.
2759- /// </summary>
2760- public abstract bool HasChildren { get; }
2761-
2762- /// <summary>
2763- /// Gets the parent as a Test object.
2764- /// Used by the core to set the parent.
2765- /// </summary>
2766- public ITest Parent
2767- {
2768- get { return parent; }
2769- set { parent = value; }
2770- }
2771-
2772- /// <summary>
2773- /// Gets this test's child tests
2774- /// </summary>
2775- /// <value>A list of child tests</value>
2776-
2777-#if CLR_2_0 || CLR_4_0
2778- public abstract System.Collections.Generic.IList<ITest> Tests { get; }
2779-#else
2780- public abstract System.Collections.IList Tests { get; }
2781-#endif
2782-
2783- #endregion
2784-
2785- #region IXmlNodeBuilder Members
2786-
2787- /// <summary>
2788- /// Returns the Xml representation of the test
2789- /// </summary>
2790- /// <param name="recursive">If true, include child tests recursively</param>
2791- /// <returns></returns>
2792- public XmlNode ToXml(bool recursive)
2793- {
2794- XmlNode topNode = XmlNode.CreateTopLevelElement("dummy");
2795-
2796- XmlNode thisNode = AddToXml(topNode, recursive);
2797-
2798- return thisNode;
2799- }
2800-
2801- /// <summary>
2802- /// Returns an XmlNode representing the current result after
2803- /// adding it as a child of the supplied parent node.
2804- /// </summary>
2805- /// <param name="parentNode">The parent node.</param>
2806- /// <param name="recursive">If true, descendant results are included</param>
2807- /// <returns></returns>
2808- public abstract XmlNode AddToXml(XmlNode parentNode, bool recursive);
2809-
2810- #endregion
2811-
2812- #region IComparable Members
2813-
2814- /// <summary>
2815- /// Compares this test to another test for sorting purposes
2816- /// </summary>
2817- /// <param name="obj">The other test</param>
2818- /// <returns>Value of -1, 0 or +1 depending on whether the current test is less than, equal to or greater than the other test</returns>
2819- public int CompareTo(object obj)
2820- {
2821- Test other = obj as Test;
2822-
2823- if (other == null)
2824- return -1;
2825-
2826- return this.FullName.CompareTo(other.FullName);
2827- }
2828-
2829- #endregion
2830-
2831- #region Other Public Methods
2832-
2833- /// <summary>
2834- /// Creates a TestResult for this test.
2835- /// </summary>
2836- /// <returns>A TestResult suitable for this type of test.</returns>
2837- public abstract TestResult MakeTestResult();
2838-
2839- ///// <summary>
2840- ///// Gets a count of test cases that would be run using
2841- ///// the specified filter.
2842- ///// </summary>
2843- ///// <param name="filter"></param>
2844- ///// <returns></returns>
2845- //public virtual int CountTestCases(TestFilter filter)
2846- //{
2847- // if (filter.Pass(this))
2848- // return 1;
2849-
2850- // return 0;
2851- //}
2852-
2853- /// <summary>
2854- /// Modify a newly constructed test by applying any of NUnit's common
2855- /// attributes, based on a supplied ICustomAttributeProvider, which is
2856- /// usually the reflection element from which the test was constructed,
2857- /// but may not be in some instances. The attributes retrieved are
2858- /// saved for use in subsequent operations.
2859- /// </summary>
2860- /// <param name="provider">An object implementing ICustomAttributeProvider</param>
2861- public void ApplyAttributesToTest(ICustomAttributeProvider provider)
2862- {
2863- foreach (IApplyToTest iApply in provider.GetCustomAttributes(typeof(IApplyToTest), true))
2864- iApply.ApplyToTest(this);
2865- }
2866-
2867- #endregion
2868-
2869- #region Protected Methods
2870-
2871- /// <summary>
2872- /// Add standard attributes and members to a test node.
2873- /// </summary>
2874- /// <param name="thisNode"></param>
2875- /// <param name="recursive"></param>
2876- protected void PopulateTestNode(XmlNode thisNode, bool recursive)
2877- {
2878- thisNode.AddAttribute("id", this.Id.ToString());
2879- thisNode.AddAttribute("name", this.Name);
2880- thisNode.AddAttribute("fullname", this.FullName);
2881-
2882- if (Properties.Count > 0)
2883- Properties.AddToXml(thisNode, recursive);
2884- }
2885-
2886- #endregion
2887-
2888- #region Internal Properties
2889-
2890- /// <summary>
2891- /// Gets or sets a fixture object for running this test.
2892- /// Provided for use by LegacySuiteBuilder.
2893- /// </summary>
2894- internal object Fixture
2895- {
2896- get { return fixture; }
2897- set { fixture = value; }
2898- }
2899-
2900- /// <summary>
2901- /// Gets the set up methods.
2902- /// </summary>
2903- /// <returns></returns>
2904- internal virtual MethodInfo[] SetUpMethods
2905- {
2906- get
2907- {
2908- if (setUpMethods == null && this.Parent != null)
2909- {
2910- TestSuite suite = this.Parent as TestSuite;
2911- if (suite != null)
2912- setUpMethods = suite.SetUpMethods;
2913- }
2914-
2915- return setUpMethods;
2916- }
2917- }
2918-
2919- /// <summary>
2920- /// Gets the tear down methods.
2921- /// </summary>
2922- /// <returns></returns>
2923- internal virtual MethodInfo[] TearDownMethods
2924- {
2925- get
2926- {
2927- if (tearDownMethods == null && this.Parent != null)
2928- {
2929- TestSuite suite = this.Parent as TestSuite;
2930- if (suite != null)
2931- tearDownMethods = suite.TearDownMethods;
2932- }
2933-
2934- return tearDownMethods;
2935- }
2936- }
2937-
2938- #endregion
2939- }
2940-}
2941+// ***********************************************************************
2942+// Copyright (c) 2012 Charlie Poole
2943+//
2944+// Permission is hereby granted, free of charge, to any person obtaining
2945+// a copy of this software and associated documentation files (the
2946+// "Software"), to deal in the Software without restriction, including
2947+// without limitation the rights to use, copy, modify, merge, publish,
2948+// distribute, sublicense, and/or sell copies of the Software, and to
2949+// permit persons to whom the Software is furnished to do so, subject to
2950+// the following conditions:
2951+//
2952+// The above copyright notice and this permission notice shall be
2953+// included in all copies or substantial portions of the Software.
2954+//
2955+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2956+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2957+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2958+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2959+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2960+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2961+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2962+// ***********************************************************************
2963+
2964+using System;
2965+using System.Reflection;
2966+using NUnit.Framework.Api;
2967+using NUnit.Framework.Internal.Commands;
2968+using NUnit.Framework.Internal.WorkItems;
2969+
2970+namespace NUnit.Framework.Internal
2971+{
2972+ /// <summary>
2973+ /// The Test abstract class represents a test within the framework.
2974+ /// </summary>
2975+ public abstract class Test : ITest, IComparable
2976+ {
2977+ #region Fields
2978+
2979+ /// <summary>
2980+ /// Static value to seed ids. It's started at 1000 so any
2981+ /// uninitialized ids will stand out.
2982+ /// </summary>
2983+ private static int nextID = 1000;
2984+
2985+ private int id;
2986+ private string name;
2987+ private string fullName;
2988+ private int seed;
2989+
2990+ /// <summary>
2991+ /// Indicates whether the test should be executed
2992+ /// </summary>
2993+ private RunState runState;
2994+
2995+ /// <summary>
2996+ /// Test suite containing this test, or null
2997+ /// </summary>
2998+ private ITest parent;
2999+
3000+ /// <summary>
3001+ /// A dictionary of properties, used to add information
3002+ /// to tests without requiring the class to change.
3003+ /// </summary>
3004+ private PropertyBag properties;
3005+
3006+ /// <summary>
3007+ /// The System.Type of the fixture for this test, if there is one
3008+ /// </summary>
3009+ private Type fixtureType;
3010+
3011+ /// <summary>
3012+ /// The fixture object, if it has been created
3013+ /// </summary>
3014+ private object fixture;
3015+
3016+ /// <summary>
3017+ /// The SetUp methods.
3018+ /// </summary>
3019+ protected MethodInfo[] setUpMethods;
3020+
3021+ /// <summary>
3022+ /// The teardown methods
3023+ /// </summary>
3024+ protected MethodInfo[] tearDownMethods;
3025+
3026+ #endregion
3027+
3028+ #region Construction
3029+
3030+ /// <summary>
3031+ /// Constructs a test given its name
3032+ /// </summary>
3033+ /// <param name="name">The name of the test</param>
3034+ protected Test( string name )
3035+ {
3036+ this.fullName = name;
3037+ this.name = name;
3038+ this.id = unchecked(nextID++);
3039+
3040+ this.runState = RunState.Runnable;
3041+ }
3042+
3043+ /// <summary>
3044+ /// Constructs a test given the path through the
3045+ /// test hierarchy to its parent and a name.
3046+ /// </summary>
3047+ /// <param name="pathName">The parent tests full name</param>
3048+ /// <param name="name">The name of the test</param>
3049+ protected Test( string pathName, string name )
3050+ {
3051+ this.fullName = pathName == null || pathName == string.Empty
3052+ ? name : pathName + "." + name;
3053+ this.name = name;
3054+ this.id = unchecked(nextID++);
3055+
3056+ this.runState = RunState.Runnable;
3057+ }
3058+
3059+ /// <summary>
3060+ /// TODO: Documentation needed for constructor
3061+ /// </summary>
3062+ /// <param name="fixtureType"></param>
3063+ protected Test(Type fixtureType) : this(fixtureType.FullName)
3064+ {
3065+ this.fixtureType = fixtureType;
3066+ }
3067+
3068+ #endregion
3069+
3070+ #region ITest Members
3071+
3072+ /// <summary>
3073+ /// Gets or sets the id of the test
3074+ /// </summary>
3075+ /// <value></value>
3076+ public int Id
3077+ {
3078+ get { return id; }
3079+ set { id = value; }
3080+ }
3081+
3082+ /// <summary>
3083+ /// Gets or sets the name of the test
3084+ /// </summary>
3085+ public string Name
3086+ {
3087+ get { return name; }
3088+ set { name = value; }
3089+ }
3090+
3091+ /// <summary>
3092+ /// Gets or sets the fully qualified name of the test
3093+ /// </summary>
3094+ /// <value></value>
3095+ public string FullName
3096+ {
3097+ get { return fullName; }
3098+ set { fullName = value; }
3099+ }
3100+
3101+ /// <summary>
3102+ /// Gets the Type of the fixture used in running this test
3103+ /// or null if no fixture type is associated with it.
3104+ /// </summary>
3105+ public Type FixtureType
3106+ {
3107+ get { return fixtureType; }
3108+ }
3109+
3110+ /// <summary>
3111+ /// Whether or not the test should be run
3112+ /// </summary>
3113+ public RunState RunState
3114+ {
3115+ get { return runState; }
3116+ set { runState = value; }
3117+ }
3118+
3119+ /// <summary>
3120+ /// Gets the name used for the top-level element in the
3121+ /// XML representation of this test
3122+ /// </summary>
3123+ public abstract string XmlElementName
3124+ {
3125+ get;
3126+ }
3127+
3128+ /// <summary>
3129+ /// Gets a string representing the type of test. Used as an attribute
3130+ /// value in the XML representation of a test and has no other
3131+ /// function in the framework.
3132+ /// </summary>
3133+ public virtual string TestType
3134+ {
3135+ get { return this.GetType().Name; }
3136+ }
3137+
3138+ /// <summary>
3139+ /// Gets a count of test cases represented by
3140+ /// or contained under this test.
3141+ /// </summary>
3142+ public virtual int TestCaseCount
3143+ {
3144+ get { return 1; }
3145+ }
3146+
3147+ /// <summary>
3148+ /// Gets the properties for this test
3149+ /// </summary>
3150+ public IPropertyBag Properties
3151+ {
3152+ get
3153+ {
3154+ if ( properties == null )
3155+ properties = new PropertyBag();
3156+
3157+ return properties;
3158+ }
3159+ }
3160+
3161+ /// <summary>
3162+ /// Gets a bool indicating whether the current test
3163+ /// has any descendant tests.
3164+ /// </summary>
3165+ public abstract bool HasChildren { get; }
3166+
3167+ /// <summary>
3168+ /// Gets the parent as a Test object.
3169+ /// Used by the core to set the parent.
3170+ /// </summary>
3171+ public ITest Parent
3172+ {
3173+ get { return parent; }
3174+ set { parent = value; }
3175+ }
3176+
3177+ /// <summary>
3178+ /// Gets or Sets the Int value representing the seed for the RandomGenerator
3179+ /// </summary>
3180+ /// <value></value>
3181+ public int Seed
3182+ {
3183+ get { return seed; }
3184+ set { seed = value; }
3185+ }
3186+
3187+ /// <summary>
3188+ /// Gets this test's child tests
3189+ /// </summary>
3190+ /// <value>A list of child tests</value>
3191+
3192+#if CLR_2_0 || CLR_4_0
3193+ public abstract System.Collections.Generic.IList<ITest> Tests { get; }
3194+#else
3195+ public abstract System.Collections.IList Tests { get; }
3196+#endif
3197+
3198+ #endregion
3199+
3200+ #region IXmlNodeBuilder Members
3201+
3202+ /// <summary>
3203+ /// Returns the Xml representation of the test
3204+ /// </summary>
3205+ /// <param name="recursive">If true, include child tests recursively</param>
3206+ /// <returns></returns>
3207+ public XmlNode ToXml(bool recursive)
3208+ {
3209+ XmlNode topNode = XmlNode.CreateTopLevelElement("dummy");
3210+
3211+ XmlNode thisNode = AddToXml(topNode, recursive);
3212+
3213+ return thisNode;
3214+ }
3215+
3216+ /// <summary>
3217+ /// Returns an XmlNode representing the current result after
3218+ /// adding it as a child of the supplied parent node.
3219+ /// </summary>
3220+ /// <param name="parentNode">The parent node.</param>
3221+ /// <param name="recursive">If true, descendant results are included</param>
3222+ /// <returns></returns>
3223+ public abstract XmlNode AddToXml(XmlNode parentNode, bool recursive);
3224+
3225+ #endregion
3226+
3227+ #region IComparable Members
3228+
3229+ /// <summary>
3230+ /// Compares this test to another test for sorting purposes
3231+ /// </summary>
3232+ /// <param name="obj">The other test</param>
3233+ /// <returns>Value of -1, 0 or +1 depending on whether the current test is less than, equal to or greater than the other test</returns>
3234+ public int CompareTo(object obj)
3235+ {
3236+ Test other = obj as Test;
3237+
3238+ if (other == null)
3239+ return -1;
3240+
3241+ return this.FullName.CompareTo(other.FullName);
3242+ }
3243+
3244+ #endregion
3245+
3246+ #region Other Public Methods
3247+
3248+ /// <summary>
3249+ /// Creates a TestResult for this test.
3250+ /// </summary>
3251+ /// <returns>A TestResult suitable for this type of test.</returns>
3252+ public abstract TestResult MakeTestResult();
3253+
3254+ ///// <summary>
3255+ ///// Gets a count of test cases that would be run using
3256+ ///// the specified filter.
3257+ ///// </summary>
3258+ ///// <param name="filter"></param>
3259+ ///// <returns></returns>
3260+ //public virtual int CountTestCases(TestFilter filter)
3261+ //{
3262+ // if (filter.Pass(this))
3263+ // return 1;
3264+
3265+ // return 0;
3266+ //}
3267+
3268+ /// <summary>
3269+ /// Modify a newly constructed test by applying any of NUnit's common
3270+ /// attributes, based on a supplied ICustomAttributeProvider, which is
3271+ /// usually the reflection element from which the test was constructed,
3272+ /// but may not be in some instances. The attributes retrieved are
3273+ /// saved for use in subsequent operations.
3274+ /// </summary>
3275+ /// <param name="provider">An object implementing ICustomAttributeProvider</param>
3276+ public void ApplyAttributesToTest(ICustomAttributeProvider provider)
3277+ {
3278+ foreach (IApplyToTest iApply in provider.GetCustomAttributes(typeof(IApplyToTest), true))
3279+ iApply.ApplyToTest(this);
3280+ }
3281+
3282+ #endregion
3283+
3284+ #region Protected Methods
3285+
3286+ /// <summary>
3287+ /// Add standard attributes and members to a test node.
3288+ /// </summary>
3289+ /// <param name="thisNode"></param>
3290+ /// <param name="recursive"></param>
3291+ protected void PopulateTestNode(XmlNode thisNode, bool recursive)
3292+ {
3293+ thisNode.AddAttribute("id", this.Id.ToString());
3294+ thisNode.AddAttribute("name", this.Name);
3295+ thisNode.AddAttribute("fullname", this.FullName);
3296+
3297+ if (Properties.Count > 0)
3298+ Properties.AddToXml(thisNode, recursive);
3299+ }
3300+
3301+ #endregion
3302+
3303+ #region Internal Properties
3304+
3305+ /// <summary>
3306+ /// Gets or sets a fixture object for running this test.
3307+ /// Provided for use by LegacySuiteBuilder.
3308+ /// </summary>
3309+ internal object Fixture
3310+ {
3311+ get { return fixture; }
3312+ set { fixture = value; }
3313+ }
3314+
3315+ /// <summary>
3316+ /// Gets the set up methods.
3317+ /// </summary>
3318+ /// <returns></returns>
3319+ internal virtual MethodInfo[] SetUpMethods
3320+ {
3321+ get
3322+ {
3323+ if (setUpMethods == null && this.Parent != null)
3324+ {
3325+ TestSuite suite = this.Parent as TestSuite;
3326+ if (suite != null)
3327+ setUpMethods = suite.SetUpMethods;
3328+ }
3329+
3330+ return setUpMethods;
3331+ }
3332+ }
3333+
3334+ /// <summary>
3335+ /// Gets the tear down methods.
3336+ /// </summary>
3337+ /// <returns></returns>
3338+ internal virtual MethodInfo[] TearDownMethods
3339+ {
3340+ get
3341+ {
3342+ if (tearDownMethods == null && this.Parent != null)
3343+ {
3344+ TestSuite suite = this.Parent as TestSuite;
3345+ if (suite != null)
3346+ tearDownMethods = suite.TearDownMethods;
3347+ }
3348+
3349+ return tearDownMethods;
3350+ }
3351+ }
3352+
3353+ #endregion
3354+ }
3355+}
3356
3357=== modified file 'src/framework/Runner/CommandLineOptions.cs'
3358--- src/framework/Runner/CommandLineOptions.cs 2012-09-15 18:55:04 +0000
3359+++ src/framework/Runner/CommandLineOptions.cs 2013-05-03 03:03:44 +0000
3360@@ -50,7 +50,9 @@
3361 private string exploreFile;
3362 private string resultFile;
3363 private string resultFormat;
3364- private string outFile;
3365+ private string outFile;
3366+ private string includeCategory;
3367+ private string excludeCategory;
3368
3369 private bool error = false;
3370
3371@@ -142,6 +144,28 @@
3372 {
3373 return ExpandToFullPath(outFile);
3374 }
3375+ }
3376+
3377+ /// <summary>
3378+ /// Gets the list of categories to include
3379+ /// </summary>
3380+ public string Include
3381+ {
3382+ get
3383+ {
3384+ return includeCategory;
3385+ }
3386+ }
3387+
3388+ /// <summary>
3389+ /// Gets the list of categories to exclude
3390+ /// </summary>
3391+ public string Exclude
3392+ {
3393+ get
3394+ {
3395+ return excludeCategory;
3396+ }
3397 }
3398
3399 /// <summary>
3400@@ -260,7 +284,13 @@
3401 outFile = val;
3402 break;
3403 case "labels":
3404- labelTestsInOutput = true;
3405+ labelTestsInOutput = true;
3406+ break;
3407+ case "include":
3408+ includeCategory = val;
3409+ break;
3410+ case "exclude":
3411+ excludeCategory = val;
3412 break;
3413 default:
3414 error = true;
3415
3416=== modified file 'src/framework/Runner/TextUI.cs'
3417--- src/framework/Runner/TextUI.cs 2013-01-24 01:32:48 +0000
3418+++ src/framework/Runner/TextUI.cs 2013-05-03 03:03:44 +0000
3419@@ -1,76 +1,76 @@
3420-// ***********************************************************************
3421-// Copyright (c) 2007 Charlie Poole
3422-//
3423-// Permission is hereby granted, free of charge, to any person obtaining
3424-// a copy of this software and associated documentation files (the
3425-// "Software"), to deal in the Software without restriction, including
3426-// without limitation the rights to use, copy, modify, merge, publish,
3427-// distribute, sublicense, and/or sell copies of the Software, and to
3428-// permit persons to whom the Software is furnished to do so, subject to
3429-// the following conditions:
3430-//
3431-// The above copyright notice and this permission notice shall be
3432-// included in all copies or substantial portions of the Software.
3433-//
3434-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3435-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3436-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3437-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
3438-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
3439-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3440-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3441-// ***********************************************************************
3442-
3443-using System;
3444-using System.IO;
3445-using System.Collections;
3446-using System.Reflection;
3447-using NUnit.Framework.Api;
3448-using NUnit.Framework.Internal;
3449-using NUnit.Framework.Internal.Filters;
3450-using System.Diagnostics;
3451-
3452-namespace NUnitLite.Runner
3453-{
3454- /// <summary>
3455- /// TextUI is a general purpose class that runs tests and
3456- /// outputs to a TextWriter.
3457- ///
3458- /// Call it from your Main like this:
3459- /// new TextUI(textWriter).Execute(args);
3460- /// OR
3461- /// new TextUI().Execute(args);
3462- /// The provided TextWriter is used by default, unless the
3463- /// arguments to Execute override it using -out. The second
3464- /// form uses the Console, provided it exists on the platform.
3465- ///
3466- /// NOTE: When running on a platform without a Console, such
3467- /// as Windows Phone, the results will simply not appear if
3468- /// you fail to specify a file in the call itself or as an option.
3469- /// </summary>
3470- public class TextUI : ITestListener
3471- {
3472- private CommandLineOptions commandLineOptions;
3473-
3474- private NUnit.ObjectList assemblies = new NUnit.ObjectList();
3475-
3476- private TextWriter writer;
3477-
3478+// ***********************************************************************
3479+// Copyright (c) 2007 Charlie Poole
3480+//
3481+// Permission is hereby granted, free of charge, to any person obtaining
3482+// a copy of this software and associated documentation files (the
3483+// "Software"), to deal in the Software without restriction, including
3484+// without limitation the rights to use, copy, modify, merge, publish,
3485+// distribute, sublicense, and/or sell copies of the Software, and to
3486+// permit persons to whom the Software is furnished to do so, subject to
3487+// the following conditions:
3488+//
3489+// The above copyright notice and this permission notice shall be
3490+// included in all copies or substantial portions of the Software.
3491+//
3492+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3493+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3494+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3495+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
3496+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
3497+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3498+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3499+// ***********************************************************************
3500+
3501+using System;
3502+using System.IO;
3503+using System.Collections;
3504+using System.Reflection;
3505+using NUnit.Framework.Api;
3506+using NUnit.Framework.Internal;
3507+using NUnit.Framework.Internal.Filters;
3508+using System.Diagnostics;
3509+
3510+namespace NUnitLite.Runner
3511+{
3512+ /// <summary>
3513+ /// TextUI is a general purpose class that runs tests and
3514+ /// outputs to a TextWriter.
3515+ ///
3516+ /// Call it from your Main like this:
3517+ /// new TextUI(textWriter).Execute(args);
3518+ /// OR
3519+ /// new TextUI().Execute(args);
3520+ /// The provided TextWriter is used by default, unless the
3521+ /// arguments to Execute override it using -out. The second
3522+ /// form uses the Console, provided it exists on the platform.
3523+ ///
3524+ /// NOTE: When running on a platform without a Console, such
3525+ /// as Windows Phone, the results will simply not appear if
3526+ /// you fail to specify a file in the call itself or as an option.
3527+ /// </summary>
3528+ public class TextUI : ITestListener
3529+ {
3530+ private CommandLineOptions commandLineOptions;
3531+
3532+ private NUnit.ObjectList assemblies = new NUnit.ObjectList();
3533+
3534+ private TextWriter writer;
3535+
3536 private ITestListener listener;
3537
3538- private ITestAssemblyRunner runner;
3539-
3540- #region Constructors
3541-
3542- /// <summary>
3543- /// Initializes a new instance of the <see cref="TextUI"/> class.
3544- /// </summary>
3545+ private ITestAssemblyRunner runner;
3546+
3547+ #region Constructors
3548+
3549+ /// <summary>
3550+ /// Initializes a new instance of the <see cref="TextUI"/> class.
3551+ /// </summary>
3552 public TextUI() : this(ConsoleWriter.Out, TestListener.NULL) { }
3553-
3554- /// <summary>
3555- /// Initializes a new instance of the <see cref="TextUI"/> class.
3556- /// </summary>
3557- /// <param name="writer">The TextWriter to use.</param>
3558+
3559+ /// <summary>
3560+ /// Initializes a new instance of the <see cref="TextUI"/> class.
3561+ /// </summary>
3562+ /// <param name="writer">The TextWriter to use.</param>
3563 public TextUI(TextWriter writer) : this(writer, TestListener.NULL) { }
3564
3565 /// <summary>
3566@@ -79,116 +79,139 @@
3567 /// <param name="writer">The TextWriter to use.</param>
3568 /// <param name="listener">The Test listener to use.</param>
3569 public TextUI(TextWriter writer, ITestListener listener)
3570- {
3571- // Set the default writer - may be overridden by the args specified
3572- this.writer = writer;
3573- this.runner = new NUnitLiteTestAssemblyRunner(new NUnitLiteTestAssemblyBuilder());
3574+ {
3575+ // Set the default writer - may be overridden by the args specified
3576+ this.writer = writer;
3577+ this.runner = new NUnitLiteTestAssemblyRunner(new NUnitLiteTestAssemblyBuilder());
3578 this.listener = listener;
3579- }
3580-
3581- #endregion
3582-
3583- #region Public Methods
3584-
3585- /// <summary>
3586- /// Execute a test run based on the aruments passed
3587- /// from Main.
3588- /// </summary>
3589- /// <param name="args">An array of arguments</param>
3590- public void Execute(string[] args)
3591- {
3592- // NOTE: Execute must be directly called from the
3593- // test assembly in order for the mechanism to work.
3594- Assembly callingAssembly = Assembly.GetCallingAssembly();
3595-
3596- this.commandLineOptions = new CommandLineOptions();
3597- commandLineOptions.Parse(args);
3598-
3599- if (commandLineOptions.OutFile != null)
3600- this.writer = new StreamWriter(commandLineOptions.OutFile);
3601-
3602- if (!commandLineOptions.NoHeader)
3603+ }
3604+
3605+ #endregion
3606+
3607+ #region Public Methods
3608+
3609+ /// <summary>
3610+ /// Execute a test run based on the aruments passed
3611+ /// from Main.
3612+ /// </summary>
3613+ /// <param name="args">An array of arguments</param>
3614+ public void Execute(string[] args)
3615+ {
3616+ // NOTE: Execute must be directly called from the
3617+ // test assembly in order for the mechanism to work.
3618+ Assembly callingAssembly = Assembly.GetCallingAssembly();
3619+
3620+ this.commandLineOptions = new CommandLineOptions();
3621+ commandLineOptions.Parse(args);
3622+
3623+ if (commandLineOptions.OutFile != null)
3624+ this.writer = new StreamWriter(commandLineOptions.OutFile);
3625+
3626+ if (!commandLineOptions.NoHeader)
3627 WriteHeader(this.writer);
3628-
3629- if (commandLineOptions.ShowHelp)
3630- writer.Write(commandLineOptions.HelpText);
3631- else if (commandLineOptions.Error)
3632- {
3633- writer.WriteLine(commandLineOptions.ErrorMessage);
3634- writer.WriteLine(commandLineOptions.HelpText);
3635- }
3636- else
3637- {
3638+
3639+ if (commandLineOptions.ShowHelp)
3640+ writer.Write(commandLineOptions.HelpText);
3641+ else if (commandLineOptions.Error)
3642+ {
3643+ writer.WriteLine(commandLineOptions.ErrorMessage);
3644+ writer.WriteLine(commandLineOptions.HelpText);
3645+ }
3646+ else
3647+ {
3648 WriteRuntimeEnvironment(this.writer);
3649-
3650- if (commandLineOptions.Wait && commandLineOptions.OutFile != null)
3651- writer.WriteLine("Ignoring /wait option - only valid for Console");
3652-
3653+
3654+ if (commandLineOptions.Wait && commandLineOptions.OutFile != null)
3655+ writer.WriteLine("Ignoring /wait option - only valid for Console");
3656+
3657 #if SILVERLIGHT
3658 IDictionary loadOptions = new System.Collections.Generic.Dictionary<string, string>();
3659 #else
3660- IDictionary loadOptions = new Hashtable();
3661+ IDictionary loadOptions = new Hashtable();
3662 #endif
3663- //if (options.Load.Count > 0)
3664- // loadOptions["LOAD"] = options.Load;
3665-
3666- //IDictionary runOptions = new Hashtable();
3667- //if (commandLineOptions.TestCount > 0)
3668- // runOptions["RUN"] = commandLineOptions.Tests;
3669-
3670- ITestFilter filter = commandLineOptions.TestCount > 0
3671- ? new SimpleNameFilter(commandLineOptions.Tests)
3672- : TestFilter.Empty;
3673-
3674- try
3675- {
3676- foreach (string name in commandLineOptions.Parameters)
3677- assemblies.Add(Assembly.Load(name));
3678-
3679- if (assemblies.Count == 0)
3680- assemblies.Add(callingAssembly);
3681-
3682- // TODO: For now, ignore all but first assembly
3683- Assembly assembly = assemblies[0] as Assembly;
3684-
3685- if (!runner.Load(assembly, loadOptions))
3686- {
3687+ //if (options.Load.Count > 0)
3688+ // loadOptions["LOAD"] = options.Load;
3689+
3690+ //IDictionary runOptions = new Hashtable();
3691+ //if (commandLineOptions.TestCount > 0)
3692+ // runOptions["RUN"] = commandLineOptions.Tests;
3693+
3694+ ITestFilter filter = commandLineOptions.TestCount > 0
3695+ ? new SimpleNameFilter(commandLineOptions.Tests)
3696+ : TestFilter.Empty;
3697+
3698+ try
3699+ {
3700+ foreach (string name in commandLineOptions.Parameters)
3701+ assemblies.Add(Assembly.Load(name));
3702+
3703+ if (assemblies.Count == 0)
3704+ assemblies.Add(callingAssembly);
3705+
3706+ // TODO: For now, ignore all but first assembly
3707+ Assembly assembly = assemblies[0] as Assembly;
3708+
3709+ if (!runner.Load(assembly, loadOptions))
3710+ {
3711 AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(assembly);
3712 Console.WriteLine("No tests found in assembly {0}", assemblyName.Name);
3713- return;
3714- }
3715-
3716- if (commandLineOptions.Explore)
3717- ExploreTests();
3718- else
3719- RunTests(filter);
3720- }
3721- catch (FileNotFoundException ex)
3722- {
3723- writer.WriteLine(ex.Message);
3724- }
3725- catch (Exception ex)
3726- {
3727- writer.WriteLine(ex.ToString());
3728- }
3729- finally
3730- {
3731- if (commandLineOptions.OutFile == null)
3732- {
3733- if (commandLineOptions.Wait)
3734- {
3735- Console.WriteLine("Press Enter key to continue . . .");
3736- Console.ReadLine();
3737- }
3738- }
3739- else
3740- {
3741- writer.Close();
3742- }
3743- }
3744- }
3745- }
3746-
3747+ return;
3748+ }
3749+
3750+ if (commandLineOptions.Explore)
3751+ ExploreTests();
3752+ else
3753+ {
3754+ if (commandLineOptions.Include != null && commandLineOptions.Include != string.Empty)
3755+ {
3756+ TestFilter includeFilter = new SimpleCategoryExpression(commandLineOptions.Include).Filter;
3757+
3758+ if (filter.IsEmpty)
3759+ filter = includeFilter;
3760+ else
3761+ filter = new AndFilter(filter, includeFilter);
3762+ }
3763+
3764+ if (commandLineOptions.Exclude != null && commandLineOptions.Exclude != string.Empty)
3765+ {
3766+ TestFilter excludeFilter = new NotFilter(new SimpleCategoryExpression(commandLineOptions.Exclude).Filter);
3767+
3768+ if (filter.IsEmpty)
3769+ filter = excludeFilter;
3770+ else if (filter is AndFilter)
3771+ ((AndFilter)filter).Add(excludeFilter);
3772+ else
3773+ filter = new AndFilter(filter, excludeFilter);
3774+ }
3775+ RunTests(filter);
3776+ }
3777+ }
3778+ catch (FileNotFoundException ex)
3779+ {
3780+ writer.WriteLine(ex.Message);
3781+ }
3782+ catch (Exception ex)
3783+ {
3784+ writer.WriteLine(ex.ToString());
3785+ }
3786+ finally
3787+ {
3788+ if (commandLineOptions.OutFile == null)
3789+ {
3790+ if (commandLineOptions.Wait)
3791+ {
3792+ Console.WriteLine("Press Enter key to continue . . .");
3793+ Console.ReadLine();
3794+ }
3795+ }
3796+ else
3797+ {
3798+ writer.Close();
3799+ }
3800+ }
3801+ }
3802+ }
3803+
3804 /// <summary>
3805 /// Write the standard header information to a TextWriter.
3806 /// </summary>
3807@@ -247,37 +270,37 @@
3808 writer.WriteLine();
3809 }
3810
3811- #endregion
3812-
3813- #region Helper Methods
3814-
3815- private void RunTests(ITestFilter filter)
3816- {
3817- ITestResult result = runner.Run(this, filter);
3818+ #endregion
3819+
3820+ #region Helper Methods
3821+
3822+ private void RunTests(ITestFilter filter)
3823+ {
3824+ ITestResult result = runner.Run(this, filter);
3825 new ResultReporter(result, writer).ReportResults();
3826- string resultFile = commandLineOptions.ResultFile;
3827- string resultFormat = commandLineOptions.ResultFormat;
3828-
3829- if (resultFile != null || commandLineOptions.ResultFormat != null)
3830- {
3831- if (resultFile == null)
3832- resultFile = "TestResult.xml";
3833-
3834- if (resultFormat == "nunit2")
3835- new NUnit2XmlOutputWriter().WriteResultFile(result, resultFile);
3836- else
3837- new NUnit3XmlOutputWriter().WriteResultFile(result, resultFile);
3838-
3839- Console.WriteLine();
3840- Console.WriteLine("Results saved as {0}.", resultFile);
3841- }
3842- }
3843-
3844- private void ExploreTests()
3845- {
3846- XmlNode testNode = runner.LoadedTest.ToXml(true);
3847-
3848- string listFile = commandLineOptions.ExploreFile;
3849+ string resultFile = commandLineOptions.ResultFile;
3850+ string resultFormat = commandLineOptions.ResultFormat;
3851+
3852+ if (resultFile != null || commandLineOptions.ResultFormat != null)
3853+ {
3854+ if (resultFile == null)
3855+ resultFile = "TestResult.xml";
3856+
3857+ if (resultFormat == "nunit2")
3858+ new NUnit2XmlOutputWriter().WriteResultFile(result, resultFile);
3859+ else
3860+ new NUnit3XmlOutputWriter().WriteResultFile(result, resultFile);
3861+
3862+ Console.WriteLine();
3863+ Console.WriteLine("Results saved as {0}.", resultFile);
3864+ }
3865+ }
3866+
3867+ private void ExploreTests()
3868+ {
3869+ XmlNode testNode = runner.LoadedTest.ToXml(true);
3870+
3871+ string listFile = commandLineOptions.ExploreFile;
3872 TextWriter textWriter = listFile != null && listFile.Length > 0
3873 ? new StreamWriter(listFile)
3874 : Console.Out;
3875@@ -292,43 +315,43 @@
3876 testWriter.Formatting = System.Xml.Formatting.Indented;
3877 #endif
3878
3879- testNode.WriteTo(testWriter);
3880- testWriter.Close();
3881-
3882- Console.WriteLine();
3883- Console.WriteLine("Test info saved as {0}.", listFile);
3884- }
3885-
3886- #endregion
3887-
3888- #region ITestListener Members
3889-
3890+ testNode.WriteTo(testWriter);
3891+ testWriter.Close();
3892+
3893+ Console.WriteLine();
3894+ Console.WriteLine("Test info saved as {0}.", listFile);
3895+ }
3896+
3897+ #endregion
3898+
3899+ #region ITestListener Members
3900+
3901 /// <summary>
3902 /// A test has just started
3903 /// </summary>
3904 /// <param name="test">The test</param>
3905- public void TestStarted(ITest test)
3906- {
3907- if (commandLineOptions.LabelTestsInOutput)
3908- writer.WriteLine("***** {0}", test.Name);
3909- }
3910-
3911- /// <summary>
3912- /// A test has just finished
3913- /// </summary>
3914- /// <param name="result">The result of the test</param>
3915- public void TestFinished(ITestResult result)
3916- {
3917- }
3918-
3919- /// <summary>
3920- /// A test has produced some text output
3921- /// </summary>
3922- /// <param name="testOutput">A TestOutput object holding the text that was written</param>
3923- public void TestOutput(TestOutput testOutput)
3924- {
3925- }
3926-
3927- #endregion
3928- }
3929-}
3930+ public void TestStarted(ITest test)
3931+ {
3932+ if (commandLineOptions.LabelTestsInOutput)
3933+ writer.WriteLine("***** {0}", test.Name);
3934+ }
3935+
3936+ /// <summary>
3937+ /// A test has just finished
3938+ /// </summary>
3939+ /// <param name="result">The result of the test</param>
3940+ public void TestFinished(ITestResult result)
3941+ {
3942+ }
3943+
3944+ /// <summary>
3945+ /// A test has produced some text output
3946+ /// </summary>
3947+ /// <param name="testOutput">A TestOutput object holding the text that was written</param>
3948+ public void TestOutput(TestOutput testOutput)
3949+ {
3950+ }
3951+
3952+ #endregion
3953+ }
3954+}
3955
3956=== modified file 'src/framework/TestContext.cs'
3957--- src/framework/TestContext.cs 2012-09-01 18:18:44 +0000
3958+++ src/framework/TestContext.cs 2013-05-03 03:03:44 +0000
3959@@ -1,249 +1,257 @@
3960-// ***********************************************************************
3961-// Copyright (c) 2011 Charlie Poole
3962-//
3963-// Permission is hereby granted, free of charge, to any person obtaining
3964-// a copy of this software and associated documentation files (the
3965-// "Software"), to deal in the Software without restriction, including
3966-// without limitation the rights to use, copy, modify, merge, publish,
3967-// distribute, sublicense, and/or sell copies of the Software, and to
3968-// permit persons to whom the Software is furnished to do so, subject to
3969-// the following conditions:
3970-//
3971-// The above copyright notice and this permission notice shall be
3972-// included in all copies or substantial portions of the Software.
3973-//
3974-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3975-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3976-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3977-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
3978-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
3979-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3980-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3981-// ***********************************************************************
3982-
3983-using System;
3984-using System.Collections;
3985-using NUnit.Framework.Api;
3986-using NUnit.Framework.Internal;
3987-
3988-namespace NUnit.Framework
3989-{
3990- /// <summary>
3991- /// Provide the context information of the current test.
3992- /// This is an adapter for the internal ExecutionContext
3993- /// class, hiding the internals from the user test.
3994- /// </summary>
3995- public class TestContext
3996- {
3997- private TestExecutionContext ec;
3998- private TestAdapter test;
3999- private ResultAdapter result;
4000-
4001- #region Constructor
4002-
4003- /// <summary>
4004- /// Construct a TestContext for an ExecutionContext
4005- /// </summary>
4006- /// <param name="ec">The ExecutionContext to adapt</param>
4007- public TestContext(TestExecutionContext ec)
4008- {
4009- this.ec = ec;
4010- }
4011-
4012- #endregion
4013-
4014- #region Properties
4015-
4016- /// <summary>
4017- /// Get the current test context. This is created
4018- /// as needed. The user may save the context for
4019- /// use within a test, but it should not be used
4020- /// outside the test for which it is created.
4021- /// </summary>
4022- public static TestContext CurrentContext
4023- {
4024- get { return new TestContext(TestExecutionContext.CurrentContext); }
4025- }
4026-
4027- /// <summary>
4028- /// Get a representation of the current test.
4029- /// </summary>
4030- public TestAdapter Test
4031- {
4032- get
4033- {
4034- if (test == null)
4035- test = new TestAdapter(ec.CurrentTest);
4036-
4037- return test;
4038- }
4039- }
4040-
4041- /// <summary>
4042- /// Gets a Representation of the TestResult for the current test.
4043- /// </summary>
4044- public ResultAdapter Result
4045- {
4046- get
4047- {
4048- if (result == null)
4049- result = new ResultAdapter(ec.CurrentResult);
4050-
4051- return result;
4052- }
4053- }
4054-
4055-#if !NETCF
4056- /// <summary>
4057- /// Gets the directory containing the current test assembly.
4058- /// </summary>
4059- public string TestDirectory
4060- {
4061- get
4062- {
4063- return AssemblyHelper.GetDirectoryName(ec.CurrentTest.FixtureType.Assembly);
4064- }
4065- }
4066-#endif
4067-
4068- /// <summary>
4069- /// Gets the directory to be used for outputing files created
4070- /// by this test run.
4071- /// </summary>
4072- public string WorkDirectory
4073- {
4074- get
4075- {
4076- return ec.WorkDirectory;
4077- }
4078- }
4079-
4080- #endregion
4081-
4082- #region Nested TestAdapter Class
4083-
4084- /// <summary>
4085- /// TestAdapter adapts a Test for consumption by
4086- /// the user test code.
4087- /// </summary>
4088- public class TestAdapter
4089- {
4090- private Test test;
4091-
4092- #region Constructor
4093-
4094- /// <summary>
4095- /// Construct a TestAdapter for a Test
4096- /// </summary>
4097- /// <param name="test">The Test to be adapted</param>
4098- public TestAdapter(Test test)
4099- {
4100- this.test = test;
4101- }
4102-
4103- #endregion
4104-
4105- #region Properties
4106-
4107- /// <summary>
4108- /// Gets the unique Id of a test
4109- /// </summary>
4110- public int ID
4111- {
4112- get { return test.Id; }
4113- }
4114-
4115- /// <summary>
4116- /// The name of the test, which may or may not be
4117- /// the same as the method name.
4118- /// </summary>
4119- public string Name
4120- {
4121- get
4122- {
4123- return test.Name;
4124- }
4125- }
4126-
4127- /// <summary>
4128- /// The name of the method representing the test.
4129- /// </summary>
4130- public string MethodName
4131- {
4132- get
4133- {
4134- return test is TestMethod
4135- ? ((TestMethod)test).Method.Name
4136- : null;
4137- }
4138- }
4139-
4140- /// <summary>
4141- /// The FullName of the test
4142- /// </summary>
4143- public string FullName
4144- {
4145- get
4146- {
4147- return test.FullName;
4148- }
4149- }
4150-
4151- /// <summary>
4152- /// The properties of the test.
4153- /// </summary>
4154- public IPropertyBag Properties
4155- {
4156- get
4157- {
4158- return test.Properties;
4159- }
4160- }
4161-
4162- #endregion
4163- }
4164-
4165- #endregion
4166-
4167- #region Nested ResultAdapter Class
4168-
4169- /// <summary>
4170- /// ResultAdapter adapts a TestResult for consumption by
4171- /// the user test code.
4172- /// </summary>
4173- public class ResultAdapter
4174- {
4175- private TestResult result;
4176-
4177- #region Constructor
4178-
4179- /// <summary>
4180- /// Construct a ResultAdapter for a TestResult
4181- /// </summary>
4182- /// <param name="result">The TestResult to be adapted</param>
4183- public ResultAdapter(TestResult result)
4184- {
4185- this.result = result;
4186- }
4187-
4188- #endregion
4189-
4190- #region Properties
4191-
4192- /// <summary>
4193- /// Gets a ResultState representing the outcome of the test.
4194- /// </summary>
4195- public ResultState Outcome
4196- {
4197- get
4198- {
4199- return result.ResultState;
4200- }
4201- }
4202-
4203- #endregion
4204- }
4205-
4206- #endregion
4207- }
4208-}
4209+// ***********************************************************************
4210+// Copyright (c) 2011 Charlie Poole
4211+//
4212+// Permission is hereby granted, free of charge, to any person obtaining
4213+// a copy of this software and associated documentation files (the
4214+// "Software"), to deal in the Software without restriction, including
4215+// without limitation the rights to use, copy, modify, merge, publish,
4216+// distribute, sublicense, and/or sell copies of the Software, and to
4217+// permit persons to whom the Software is furnished to do so, subject to
4218+// the following conditions:
4219+//
4220+// The above copyright notice and this permission notice shall be
4221+// included in all copies or substantial portions of the Software.
4222+//
4223+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4224+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4225+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4226+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
4227+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
4228+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
4229+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4230+// ***********************************************************************
4231+
4232+using System;
4233+using System.Collections;
4234+using NUnit.Framework.Api;
4235+using NUnit.Framework.Internal;
4236+
4237+namespace NUnit.Framework
4238+{
4239+ /// <summary>
4240+ /// Provide the context information of the current test.
4241+ /// This is an adapter for the internal ExecutionContext
4242+ /// class, hiding the internals from the user test.
4243+ /// </summary>
4244+ public class TestContext
4245+ {
4246+ private TestExecutionContext ec;
4247+ private TestAdapter test;
4248+ private ResultAdapter result;
4249+
4250+ #region Constructor
4251+
4252+ /// <summary>
4253+ /// Construct a TestContext for an ExecutionContext
4254+ /// </summary>
4255+ /// <param name="ec">The ExecutionContext to adapt</param>
4256+ public TestContext(TestExecutionContext ec)
4257+ {
4258+ this.ec = ec;
4259+ }
4260+
4261+ #endregion
4262+
4263+ #region Properties
4264+
4265+ /// <summary>
4266+ /// Get the current test context. This is created
4267+ /// as needed. The user may save the context for
4268+ /// use within a test, but it should not be used
4269+ /// outside the test for which it is created.
4270+ /// </summary>
4271+ public static TestContext CurrentContext
4272+ {
4273+ get { return new TestContext(TestExecutionContext.CurrentContext); }
4274+ }
4275+
4276+ /// <summary>
4277+ /// Get a representation of the current test.
4278+ /// </summary>
4279+ public TestAdapter Test
4280+ {
4281+ get
4282+ {
4283+ if (test == null)
4284+ test = new TestAdapter(ec.CurrentTest);
4285+
4286+ return test;
4287+ }
4288+ }
4289+
4290+ /// <summary>
4291+ /// Gets a Representation of the TestResult for the current test.
4292+ /// </summary>
4293+ public ResultAdapter Result
4294+ {
4295+ get
4296+ {
4297+ if (result == null)
4298+ result = new ResultAdapter(ec.CurrentResult);
4299+
4300+ return result;
4301+ }
4302+ }
4303+
4304+#if !NETCF
4305+ /// <summary>
4306+ /// Gets the directory containing the current test assembly.
4307+ /// </summary>
4308+ public string TestDirectory
4309+ {
4310+ get
4311+ {
4312+ return AssemblyHelper.GetDirectoryName(ec.CurrentTest.FixtureType.Assembly);
4313+ }
4314+ }
4315+#endif
4316+
4317+ /// <summary>
4318+ /// Gets the directory to be used for outputing files created
4319+ /// by this test run.
4320+ /// </summary>
4321+ public string WorkDirectory
4322+ {
4323+ get
4324+ {
4325+ return ec.WorkDirectory;
4326+ }
4327+ }
4328+
4329+ public RandomGenerator Random
4330+ {
4331+ get
4332+ {
4333+ return ec.Random;
4334+ }
4335+ }
4336+
4337+ #endregion
4338+
4339+ #region Nested TestAdapter Class
4340+
4341+ /// <summary>
4342+ /// TestAdapter adapts a Test for consumption by
4343+ /// the user test code.
4344+ /// </summary>
4345+ public class TestAdapter
4346+ {
4347+ private Test test;
4348+
4349+ #region Constructor
4350+
4351+ /// <summary>
4352+ /// Construct a TestAdapter for a Test
4353+ /// </summary>
4354+ /// <param name="test">The Test to be adapted</param>
4355+ public TestAdapter(Test test)
4356+ {
4357+ this.test = test;
4358+ }
4359+
4360+ #endregion
4361+
4362+ #region Properties
4363+
4364+ /// <summary>
4365+ /// Gets the unique Id of a test
4366+ /// </summary>
4367+ public int ID
4368+ {
4369+ get { return test.Id; }
4370+ }
4371+
4372+ /// <summary>
4373+ /// The name of the test, which may or may not be
4374+ /// the same as the method name.
4375+ /// </summary>
4376+ public string Name
4377+ {
4378+ get
4379+ {
4380+ return test.Name;
4381+ }
4382+ }
4383+
4384+ /// <summary>
4385+ /// The name of the method representing the test.
4386+ /// </summary>
4387+ public string MethodName
4388+ {
4389+ get
4390+ {
4391+ return test is TestMethod
4392+ ? ((TestMethod)test).Method.Name
4393+ : null;
4394+ }
4395+ }
4396+
4397+ /// <summary>
4398+ /// The FullName of the test
4399+ /// </summary>
4400+ public string FullName
4401+ {
4402+ get
4403+ {
4404+ return test.FullName;
4405+ }
4406+ }
4407+
4408+ /// <summary>
4409+ /// The properties of the test.
4410+ /// </summary>
4411+ public IPropertyBag Properties
4412+ {
4413+ get
4414+ {
4415+ return test.Properties;
4416+ }
4417+ }
4418+
4419+ #endregion
4420+ }
4421+
4422+ #endregion
4423+
4424+ #region Nested ResultAdapter Class
4425+
4426+ /// <summary>
4427+ /// ResultAdapter adapts a TestResult for consumption by
4428+ /// the user test code.
4429+ /// </summary>
4430+ public class ResultAdapter
4431+ {
4432+ private TestResult result;
4433+
4434+ #region Constructor
4435+
4436+ /// <summary>
4437+ /// Construct a ResultAdapter for a TestResult
4438+ /// </summary>
4439+ /// <param name="result">The TestResult to be adapted</param>
4440+ public ResultAdapter(TestResult result)
4441+ {
4442+ this.result = result;
4443+ }
4444+
4445+ #endregion
4446+
4447+ #region Properties
4448+
4449+ /// <summary>
4450+ /// Gets a ResultState representing the outcome of the test.
4451+ /// </summary>
4452+ public ResultState Outcome
4453+ {
4454+ get
4455+ {
4456+ return result.ResultState;
4457+ }
4458+ }
4459+
4460+ #endregion
4461+ }
4462+
4463+ #endregion
4464+ }
4465+}
4466
4467=== modified file 'src/framework/nunitlite-2.0.csproj'
4468--- src/framework/nunitlite-2.0.csproj 2013-05-02 22:06:03 +0000
4469+++ src/framework/nunitlite-2.0.csproj 2013-05-03 03:03:44 +0000
4470@@ -82,6 +82,7 @@
4471 <SubType>Code</SubType>
4472 </Compile>
4473 <Compile Include="Internal\Commands\TheoryResultCommand.cs" />
4474+ <Compile Include="Internal\Filters\SimpleCategoryExpression.cs" />
4475 <Compile Include="Internal\IApplyToContext.cs" />
4476 <Compile Include="Internal\IApplyToTest.cs" />
4477 <Compile Include="Api\IParameterDataSource.cs" />
4478@@ -304,6 +305,7 @@
4479 <SubType>Code</SubType>
4480 </Compile>
4481 <Compile Include="Internal\PropertyNames.cs" />
4482+ <Compile Include="Internal\RandomGenerator.cs" />
4483 <Compile Include="Internal\Randomizer.cs" />
4484 <Compile Include="Internal\Reflect.cs" />
4485 <Compile Include="Internal\Results\TestCaseResult.cs" />
4486@@ -375,11 +377,11 @@
4487 <None Include="nunit.snk" />
4488 </ItemGroup>
4489 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4490- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4491- Other similar extension points exist, see Microsoft.Common.targets.
4492- <Target Name="BeforeBuild">
4493- </Target>
4494- <Target Name="AfterBuild">
4495- </Target>
4496+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4497+ Other similar extension points exist, see Microsoft.Common.targets.
4498+ <Target Name="BeforeBuild">
4499+ </Target>
4500+ <Target Name="AfterBuild">
4501+ </Target>
4502 -->
4503 </Project>
4504\ No newline at end of file
4505
4506=== modified file 'src/framework/nunitlite-3.5.csproj'
4507--- src/framework/nunitlite-3.5.csproj 2013-05-02 22:06:03 +0000
4508+++ src/framework/nunitlite-3.5.csproj 2013-05-03 03:03:44 +0000
4509@@ -274,6 +274,7 @@
4510 <Compile Include="Internal\Filters\CategoryFilter.cs" />
4511 <Compile Include="Internal\Filters\NotFilter.cs" />
4512 <Compile Include="Internal\Filters\OrFilter.cs" />
4513+ <Compile Include="Internal\Filters\SimpleCategoryExpression.cs" />
4514 <Compile Include="Internal\Filters\SimpleNameFilter.cs" />
4515 <Compile Include="Internal\IApplyToContext.cs" />
4516 <Compile Include="Internal\IApplyToTest.cs" />
4517@@ -287,6 +288,7 @@
4518 <Compile Include="Internal\PlatformHelper.cs" />
4519 <Compile Include="Internal\PropertyBag.cs" />
4520 <Compile Include="Internal\PropertyNames.cs" />
4521+ <Compile Include="Internal\RandomGenerator.cs" />
4522 <Compile Include="Internal\Randomizer.cs" />
4523 <Compile Include="Internal\Reflect.cs" />
4524 <Compile Include="Internal\Results\TestCaseResult.cs" />
4525@@ -358,11 +360,11 @@
4526 <None Include="nunit.snk" />
4527 </ItemGroup>
4528 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4529- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4530- Other similar extension points exist, see Microsoft.Common.targets.
4531- <Target Name="BeforeBuild">
4532- </Target>
4533- <Target Name="AfterBuild">
4534- </Target>
4535+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4536+ Other similar extension points exist, see Microsoft.Common.targets.
4537+ <Target Name="BeforeBuild">
4538+ </Target>
4539+ <Target Name="AfterBuild">
4540+ </Target>
4541 -->
4542 </Project>
4543\ No newline at end of file
4544
4545=== modified file 'src/framework/nunitlite-4.0.csproj'
4546--- src/framework/nunitlite-4.0.csproj 2013-05-02 22:06:03 +0000
4547+++ src/framework/nunitlite-4.0.csproj 2013-05-03 03:03:44 +0000
4548@@ -274,6 +274,7 @@
4549 <Compile Include="Internal\Filters\CategoryFilter.cs" />
4550 <Compile Include="Internal\Filters\NotFilter.cs" />
4551 <Compile Include="Internal\Filters\OrFilter.cs" />
4552+ <Compile Include="Internal\Filters\SimpleCategoryExpression.cs" />
4553 <Compile Include="Internal\Filters\SimpleNameFilter.cs" />
4554 <Compile Include="Internal\IApplyToContext.cs" />
4555 <Compile Include="Internal\IApplyToTest.cs" />
4556@@ -287,6 +288,7 @@
4557 <Compile Include="Internal\PlatformHelper.cs" />
4558 <Compile Include="Internal\PropertyBag.cs" />
4559 <Compile Include="Internal\PropertyNames.cs" />
4560+ <Compile Include="Internal\RandomGenerator.cs" />
4561 <Compile Include="Internal\Randomizer.cs" />
4562 <Compile Include="Internal\Reflect.cs" />
4563 <Compile Include="Internal\Results\TestCaseResult.cs" />
4564@@ -357,11 +359,11 @@
4565 <None Include="nunit.snk" />
4566 </ItemGroup>
4567 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4568- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4569- Other similar extension points exist, see Microsoft.Common.targets.
4570- <Target Name="BeforeBuild">
4571- </Target>
4572- <Target Name="AfterBuild">
4573- </Target>
4574+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
4575+ Other similar extension points exist, see Microsoft.Common.targets.
4576+ <Target Name="BeforeBuild">
4577+ </Target>
4578+ <Target Name="AfterBuild">
4579+ </Target>
4580 -->
4581 </Project>
4582\ No newline at end of file
4583
4584=== modified file 'src/framework/nunitlite-4.5.csproj'
4585--- src/framework/nunitlite-4.5.csproj 2012-12-31 04:29:18 +0000
4586+++ src/framework/nunitlite-4.5.csproj 2013-05-03 03:03:44 +0000
4587@@ -1,371 +1,373 @@
4588-<?xml version="1.0" encoding="utf-8"?>
4589-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
4590- <PropertyGroup>
4591- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4592- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
4593- <ProductVersion>9.0.30729</ProductVersion>
4594- <SchemaVersion>2.0</SchemaVersion>
4595- <ProjectGuid>{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}</ProjectGuid>
4596- <OutputType>Library</OutputType>
4597- <AppDesignerFolder>Properties</AppDesignerFolder>
4598- <RootNamespace>NUnitLite</RootNamespace>
4599- <AssemblyName>nunitlite</AssemblyName>
4600- <FileUpgradeFlags>
4601- </FileUpgradeFlags>
4602- <OldToolsVersion>3.5</OldToolsVersion>
4603- <UpgradeBackupLocation>
4604- </UpgradeBackupLocation>
4605- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
4606- <PublishUrl>publish\</PublishUrl>
4607- <Install>true</Install>
4608- <InstallFrom>Disk</InstallFrom>
4609- <UpdateEnabled>false</UpdateEnabled>
4610- <UpdateMode>Foreground</UpdateMode>
4611- <UpdateInterval>7</UpdateInterval>
4612- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
4613- <UpdatePeriodically>false</UpdatePeriodically>
4614- <UpdateRequired>false</UpdateRequired>
4615- <MapFileExtensions>true</MapFileExtensions>
4616- <ApplicationRevision>0</ApplicationRevision>
4617- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
4618- <IsWebBootstrapper>false</IsWebBootstrapper>
4619- <UseApplicationTrust>false</UseApplicationTrust>
4620- <BootstrapperEnabled>true</BootstrapperEnabled>
4621- <TargetFrameworkProfile />
4622- <IntermediateOutputPath>obj\$(Configuration)\net-4.5\</IntermediateOutputPath>
4623- </PropertyGroup>
4624- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
4625- <DebugSymbols>true</DebugSymbols>
4626- <DebugType>full</DebugType>
4627- <Optimize>false</Optimize>
4628- <OutputPath>..\..\bin\Debug\net-4.5\</OutputPath>
4629- <DefineConstants>TRACE;DEBUG;NET_4_5, CLR_4_0,NUNITLITE</DefineConstants>
4630- <ErrorReport>prompt</ErrorReport>
4631- <WarningLevel>4</WarningLevel>
4632- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
4633- <DocumentationFile>..\..\bin\Debug\net-4.5\nunitlite.xml</DocumentationFile>
4634- <Prefer32Bit>false</Prefer32Bit>
4635- </PropertyGroup>
4636- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4637- <DebugType>pdbonly</DebugType>
4638- <Optimize>true</Optimize>
4639- <OutputPath>..\..\bin\Release\net-4.5\</OutputPath>
4640- <DefineConstants>TRACE;NET_4_5, CLR_4_0,NUNITLITE</DefineConstants>
4641- <ErrorReport>prompt</ErrorReport>
4642- <WarningLevel>4</WarningLevel>
4643- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
4644- <DocumentationFile>..\..\bin\Release\net-4.5\nunitlite.xml</DocumentationFile>
4645- <Prefer32Bit>false</Prefer32Bit>
4646- </PropertyGroup>
4647- <PropertyGroup>
4648- <SignAssembly>true</SignAssembly>
4649- </PropertyGroup>
4650- <PropertyGroup>
4651- <AssemblyOriginatorKeyFile>nunit.snk</AssemblyOriginatorKeyFile>
4652- </PropertyGroup>
4653- <ItemGroup>
4654- <Reference Include="System" />
4655- <Reference Include="System.Xml" />
4656- </ItemGroup>
4657- <ItemGroup>
4658- <Compile Include="Api\ExpectedExceptionData.cs" />
4659- <Compile Include="Api\FailureSite.cs" />
4660- <Compile Include="Api\IParameterDataSource.cs" />
4661- <Compile Include="Api\IPropertyBag.cs" />
4662- <Compile Include="Api\ITest.cs" />
4663- <Compile Include="Api\ITestAssemblyBuilder.cs" />
4664- <Compile Include="Api\ITestAssemblyRunner.cs" />
4665- <Compile Include="Api\ITestCaseData.cs" />
4666- <Compile Include="Api\ITestCaseSource.cs" />
4667- <Compile Include="Api\ITestFilter.cs" />
4668- <Compile Include="Api\ITestListener.cs" />
4669- <Compile Include="Api\ITestResult.cs" />
4670- <Compile Include="Api\IXmlNodeBuilder.cs" />
4671- <Compile Include="Api\PropertyEntry.cs" />
4672- <Compile Include="Api\ResultState.cs" />
4673- <Compile Include="Api\RunState.cs" />
4674- <Compile Include="Api\TestOutput.cs" />
4675- <Compile Include="Api\TestStatus.cs" />
4676- <Compile Include="Api\XmlNode.cs" />
4677- <Compile Include="AssemblyInfo.cs" />
4678- <Compile Include="Assert.cs" />
4679- <Compile Include="AssertionHelper.cs" />
4680- <Compile Include="Assume.cs" />
4681- <Compile Include="Attributes\CategoryAttribute.cs" />
4682- <Compile Include="Attributes\CombinatorialAttribute.cs" />
4683- <Compile Include="Attributes\CultureAttribute.cs" />
4684- <Compile Include="Attributes\DataAttribute.cs" />
4685- <Compile Include="Attributes\DatapointAttribute.cs" />
4686- <Compile Include="Attributes\DatapointsAttribute.cs" />
4687- <Compile Include="Attributes\DatapointSourceAttribute.cs" />
4688- <Compile Include="Attributes\DescriptionAttribute.cs" />
4689- <Compile Include="Attributes\ExpectedExceptionAttribute.cs" />
4690- <Compile Include="Attributes\ExplicitAttribute.cs" />
4691- <Compile Include="Attributes\IgnoreAttribute.cs" />
4692- <Compile Include="Attributes\IncludeExcludeAttribute.cs" />
4693- <Compile Include="Attributes\MaxTimeAttribute.cs" />
4694- <Compile Include="Attributes\NUnitAttribute.cs" />
4695- <Compile Include="Attributes\PairwiseAttribute.cs" />
4696- <Compile Include="Attributes\PlatformAttribute.cs" />
4697- <Compile Include="Attributes\PropertyAttribute.cs" />
4698- <Compile Include="Attributes\RandomAttribute.cs" />
4699- <Compile Include="Attributes\RangeAttribute.cs" />
4700- <Compile Include="Attributes\RepeatAttribute.cs" />
4701- <Compile Include="Attributes\SequentialAttribute.cs" />
4702- <Compile Include="Attributes\SetCultureAttribute.cs" />
4703- <Compile Include="Attributes\SetUICultureAttribute.cs" />
4704- <Compile Include="Attributes\SetUpAttribute.cs" />
4705- <Compile Include="Attributes\TearDownAttribute.cs" />
4706- <Compile Include="Attributes\TestAttribute.cs" />
4707- <Compile Include="Attributes\TestCaseAttribute.cs" />
4708- <Compile Include="Attributes\TestCaseSourceAttribute.cs" />
4709- <Compile Include="Attributes\TestFixtureAttribute.cs" />
4710- <Compile Include="Attributes\TestFixtureSetUpAttribute.cs" />
4711- <Compile Include="Attributes\TestFixtureTearDownAttribute.cs" />
4712- <Compile Include="Attributes\TheoryAttribute.cs" />
4713- <Compile Include="Attributes\TimeoutAttribute.cs" />
4714- <Compile Include="Attributes\ValuesAttribute.cs" />
4715- <Compile Include="Attributes\ValueSourceAttribute.cs" />
4716- <Compile Include="Constraints\AllItemsConstraint.cs" />
4717- <Compile Include="Constraints\AndConstraint.cs" />
4718- <Compile Include="Constraints\AssignableFromConstraint.cs" />
4719- <Compile Include="Constraints\AssignableToConstraint.cs" />
4720- <Compile Include="Constraints\AttributeConstraint.cs" />
4721- <Compile Include="Constraints\AttributeExistsConstraint.cs" />
4722- <Compile Include="Constraints\BasicConstraint.cs" />
4723- <Compile Include="Constraints\BinaryConstraint.cs" />
4724- <Compile Include="Constraints\BinarySerializableConstraint.cs" />
4725- <Compile Include="Constraints\CollectionConstraint.cs" />
4726- <Compile Include="Constraints\CollectionContainsConstraint.cs" />
4727- <Compile Include="Constraints\CollectionEquivalentConstraint.cs" />
4728- <Compile Include="Constraints\CollectionItemsEqualConstraint.cs" />
4729- <Compile Include="Constraints\CollectionOrderedConstraint.cs" />
4730- <Compile Include="Constraints\CollectionSubsetConstraint.cs" />
4731- <Compile Include="Constraints\CollectionTally.cs" />
4732- <Compile Include="Constraints\ComparisonAdapter.cs" />
4733- <Compile Include="Constraints\ComparisonConstraint.cs" />
4734- <Compile Include="Constraints\Constraint.cs" />
4735- <Compile Include="Constraints\ConstraintBuilder.cs" />
4736- <Compile Include="Constraints\ConstraintExpression.cs" />
4737- <Compile Include="Constraints\ConstraintExpressionBase.cs" />
4738- <Compile Include="Constraints\ConstraintFactory.cs" />
4739- <Compile Include="Constraints\ContainsConstraint.cs" />
4740- <Compile Include="Constraints\DelayedConstraint.cs" />
4741- <Compile Include="Constraints\EmptyCollectionConstraint.cs" />
4742- <Compile Include="Constraints\EmptyConstraint.cs" />
4743- <Compile Include="Constraints\EmptyDirectoryConstraint.cs" />
4744- <Compile Include="Constraints\EmptyStringConstraint.cs" />
4745- <Compile Include="Constraints\EndsWithConstraint.cs" />
4746- <Compile Include="Constraints\EqualConstraint.cs" />
4747- <Compile Include="Constraints\EqualityAdapter.cs" />
4748- <Compile Include="Constraints\ExactCountConstraint.cs" />
4749- <Compile Include="Constraints\ExactTypeConstraint.cs" />
4750- <Compile Include="Constraints\ExceptionTypeConstraint.cs" />
4751- <Compile Include="Constraints\FailurePoint.cs" />
4752- <Compile Include="Constraints\FalseConstraint.cs" />
4753- <Compile Include="Constraints\FloatingPointNumerics.cs" />
4754- <Compile Include="Constraints\GreaterThanConstraint.cs" />
4755- <Compile Include="Constraints\GreaterThanOrEqualConstraint.cs" />
4756- <Compile Include="Constraints\InstanceOfTypeConstraint.cs" />
4757- <Compile Include="Constraints\IResolveConstraint.cs" />
4758- <Compile Include="Constraints\LessThanConstraint.cs" />
4759- <Compile Include="Constraints\LessThanOrEqualConstraint.cs" />
4760- <Compile Include="Constraints\MessageWriter.cs" />
4761- <Compile Include="Constraints\MsgUtils.cs" />
4762- <Compile Include="Constraints\NaNConstraint.cs" />
4763- <Compile Include="Constraints\NoItemConstraint.cs" />
4764- <Compile Include="Constraints\NotConstraint.cs" />
4765- <Compile Include="Constraints\NullConstraint.cs" />
4766- <Compile Include="Constraints\NullOrEmptyStringConstraint.cs" />
4767- <Compile Include="Constraints\Numerics.cs" />
4768- <Compile Include="Constraints\NUnitComparer.cs" />
4769- <Compile Include="Constraints\NUnitEqualityComparer.cs" />
4770- <Compile Include="Constraints\Operators\AllOperator.cs" />
4771- <Compile Include="Constraints\Operators\AndOperator.cs" />
4772- <Compile Include="Constraints\Operators\AttributeOperator.cs" />
4773- <Compile Include="Constraints\Operators\BinaryOperator.cs" />
4774- <Compile Include="Constraints\Operators\CollectionOperator.cs" />
4775- <Compile Include="Constraints\Operators\ConstraintOperator.cs" />
4776- <Compile Include="Constraints\Operators\ExactCountOperator.cs" />
4777- <Compile Include="Constraints\Operators\NoneOperator.cs" />
4778- <Compile Include="Constraints\Operators\NotOperator.cs" />
4779- <Compile Include="Constraints\Operators\OrOperator.cs" />
4780- <Compile Include="Constraints\Operators\PrefixOperator.cs" />
4781- <Compile Include="Constraints\Operators\PropOperator.cs" />
4782- <Compile Include="Constraints\Operators\SelfResolvingOperator.cs" />
4783- <Compile Include="Constraints\Operators\SomeOperator.cs" />
4784- <Compile Include="Constraints\Operators\ThrowsOperator.cs" />
4785- <Compile Include="Constraints\Operators\WithOperator.cs" />
4786- <Compile Include="Constraints\OrConstraint.cs" />
4787- <Compile Include="Constraints\PathConstraint.cs" />
4788- <Compile Include="Constraints\PredicateConstraint.cs" />
4789- <Compile Include="Constraints\PrefixConstraint.cs" />
4790- <Compile Include="Constraints\PropertyConstraint.cs" />
4791- <Compile Include="Constraints\PropertyExistsConstraint.cs" />
4792- <Compile Include="Constraints\RangeConstraint.cs" />
4793- <Compile Include="Constraints\RegexConstraint.cs" />
4794- <Compile Include="Constraints\ResolvableConstraintExpression.cs" />
4795- <Compile Include="Constraints\ReusableConstraint.cs" />
4796- <Compile Include="Constraints\SameAsConstraint.cs" />
4797- <Compile Include="Constraints\SamePathConstraint.cs" />
4798- <Compile Include="Constraints\SamePathOrUnderConstraint.cs" />
4799- <Compile Include="Constraints\SomeItemsConstraint.cs" />
4800- <Compile Include="Constraints\StartsWithConstraint.cs" />
4801- <Compile Include="Constraints\StringConstraint.cs" />
4802- <Compile Include="Constraints\SubPathConstraint.cs" />
4803- <Compile Include="Constraints\SubstringConstraint.cs" />
4804- <Compile Include="Constraints\ThrowsConstraint.cs" />
4805- <Compile Include="Constraints\ThrowsNothingConstraint.cs" />
4806- <Compile Include="Constraints\Tolerance.cs" />
4807- <Compile Include="Constraints\ToleranceMode.cs" />
4808- <Compile Include="Constraints\TrueConstraint.cs" />
4809- <Compile Include="Constraints\TypeConstraint.cs" />
4810- <Compile Include="Constraints\UniqueItemsConstraint.cs" />
4811- <Compile Include="Constraints\XmlSerializableConstraint.cs" />
4812- <Compile Include="Contains.cs" />
4813- <Compile Include="Env.cs" />
4814- <Compile Include="Exceptions\AssertionException.cs" />
4815- <Compile Include="Exceptions\IgnoreException.cs" />
4816- <Compile Include="Exceptions\InconclusiveException.cs" />
4817- <Compile Include="Exceptions\SuccessException.cs" />
4818- <Compile Include="Extensibility\IParameterDataProvider.cs" />
4819- <Compile Include="Extensibility\ISuiteBuilder.cs" />
4820- <Compile Include="Extensibility\ITestCaseBuilder.cs" />
4821- <Compile Include="Extensibility\ITestCaseProvider.cs" />
4822- <Compile Include="GlobalSettings.cs" />
4823- <Compile Include="Guard.cs" />
4824- <Compile Include="Has.cs" />
4825- <Compile Include="IExpectException.cs" />
4826- <Compile Include="Internal\AssemblyHelper.cs" />
4827- <Compile Include="Internal\Builders\CombinatorialStrategy.cs" />
4828- <Compile Include="Internal\Builders\CombinatorialTestCaseProvider.cs">
4829- <SubType>Code</SubType>
4830- </Compile>
4831- <Compile Include="Internal\Builders\CombiningStrategy.cs" />
4832- <Compile Include="Internal\Builders\DataAttributeTestCaseProvider.cs">
4833- <SubType>Code</SubType>
4834- </Compile>
4835- <Compile Include="Internal\Builders\DatapointProvider.cs" />
4836- <Compile Include="Internal\Builders\NUnitTestCaseBuilder.cs" />
4837- <Compile Include="Internal\Builders\NUnitTestFixtureBuilder.cs" />
4838- <Compile Include="Internal\Builders\PairwiseStrategy.cs" />
4839- <Compile Include="Internal\Builders\ParameterDataProvider.cs" />
4840- <Compile Include="Internal\Builders\ProviderCache.cs" />
4841- <Compile Include="Internal\Builders\SequentialStrategy.cs" />
4842- <Compile Include="Internal\Commands\ApplyChangesToContextCommand.cs" />
4843- <Compile Include="Internal\AsyncInvocationRegion.cs" />
4844- <Compile Include="Internal\AsyncSynchronizationContext.cs" />
4845- <Compile Include="Internal\Commands\CommandDecoratorList.cs" />
4846- <Compile Include="Internal\Commands\CommandStage.cs" />
4847- <Compile Include="Internal\Commands\DelegatingTestCommand.cs" />
4848- <Compile Include="Internal\Commands\ExpectedExceptionCommand.cs" />
4849- <Compile Include="Internal\Commands\ICommandDecorator.cs" />
4850- <Compile Include="Internal\Commands\MaxTimeCommand.cs" />
4851- <Compile Include="Internal\Commands\OneTimeSetUpCommand.cs" />
4852- <Compile Include="Internal\Commands\OneTimeTearDownCommand.cs" />
4853- <Compile Include="Internal\Commands\RepeatedTestCommand.cs" />
4854- <Compile Include="Internal\Commands\SetUpTearDownCommand.cs" />
4855- <Compile Include="Internal\Commands\SkipCommand.cs" />
4856- <Compile Include="Internal\Commands\TestCommand.cs" />
4857- <Compile Include="Internal\Commands\TestMethodCommand.cs" />
4858- <Compile Include="Internal\Commands\TheoryResultCommand.cs" />
4859- <Compile Include="Internal\CultureDetector.cs" />
4860- <Compile Include="Internal\ExceptionHelper.cs" />
4861- <Compile Include="Internal\Extensibility\ParameterDataProviders.cs" />
4862- <Compile Include="Internal\Extensibility\TestCaseProviders.cs" />
4863- <Compile Include="Internal\Filters\AndFilter.cs" />
4864- <Compile Include="Internal\Filters\CategoryExpression.cs" />
4865- <Compile Include="Internal\Filters\CategoryFilter.cs" />
4866- <Compile Include="Internal\Filters\NotFilter.cs" />
4867- <Compile Include="Internal\Filters\OrFilter.cs" />
4868- <Compile Include="Internal\Filters\SimpleNameFilter.cs" />
4869- <Compile Include="Internal\IApplyToContext.cs" />
4870- <Compile Include="Internal\IApplyToTest.cs" />
4871- <Compile Include="Internal\InvalidTestFixtureException.cs" />
4872- <Compile Include="Internal\MethodHelper.cs" />
4873- <Compile Include="Internal\NUnitException.cs" />
4874- <Compile Include="Internal\NUnitLiteTestAssemblyBuilder.cs" />
4875- <Compile Include="Internal\NUnitLiteTestAssemblyRunner.cs" />
4876- <Compile Include="Internal\OSPlatform.cs" />
4877- <Compile Include="Internal\ParameterSet.cs" />
4878- <Compile Include="Internal\PlatformHelper.cs" />
4879- <Compile Include="Internal\PropertyBag.cs" />
4880- <Compile Include="Internal\PropertyNames.cs" />
4881- <Compile Include="Internal\Randomizer.cs" />
4882- <Compile Include="Internal\Reflect.cs" />
4883- <Compile Include="Internal\Results\TestCaseResult.cs" />
4884- <Compile Include="Internal\Results\TestResult.cs" />
4885- <Compile Include="Internal\Results\TestSuiteResult.cs" />
4886- <Compile Include="Internal\RuntimeFramework.cs" />
4887- <Compile Include="Internal\StackFilter.cs" />
4888- <Compile Include="Internal\StringUtil.cs" />
4889- <Compile Include="Internal\TestExecutionContext.cs" />
4890- <Compile Include="Internal\TestFilter.cs" />
4891- <Compile Include="Internal\TestFixtureBuilder.cs" />
4892- <Compile Include="Internal\TestListener.cs" />
4893- <Compile Include="Internal\Tests\ParameterizedFixtureSuite.cs" />
4894- <Compile Include="Internal\Tests\ParameterizedMethodSuite.cs" />
4895- <Compile Include="Internal\Tests\Test.cs" />
4896- <Compile Include="Internal\Tests\TestAssembly.cs" />
4897- <Compile Include="Internal\Tests\TestFixture.cs" />
4898- <Compile Include="Internal\Tests\TestMethod.cs" />
4899- <Compile Include="Internal\Tests\TestSuite.cs" />
4900- <Compile Include="Internal\TextMessageWriter.cs" />
4901- <Compile Include="Internal\ThreadUtility.cs" />
4902- <Compile Include="Internal\TypeHelper.cs" />
4903- <Compile Include="Internal\WorkItems\CompositeWorkItem.cs" />
4904- <Compile Include="Internal\WorkItems\SimpleWorkItem.cs" />
4905- <Compile Include="Internal\WorkItems\WorkItem.cs" />
4906- <Compile Include="Internal\WorkItems\WorkItemState.cs" />
4907- <Compile Include="Is.cs" />
4908- <Compile Include="Iz.cs" />
4909- <Compile Include="ListMapper.cs" />
4910- <Compile Include="MessageMatch.cs" />
4911- <Compile Include="ObjectList.cs" />
4912- <Compile Include="Runner\CommandLineOptions.cs" />
4913- <Compile Include="Runner\ConsoleWriter.cs" />
4914- <Compile Include="Runner\DebugWriter.cs" />
4915- <Compile Include="Runner\OutputWriters\NUnit2XmlOutputWriter.cs" />
4916- <Compile Include="Runner\OutputWriters\NUnit3XmlOutputWriter.cs" />
4917- <Compile Include="Runner\OutputWriters\OutputWriter.cs" />
4918- <Compile Include="Runner\ResultReporter.cs" />
4919- <Compile Include="Runner\ResultSummary.cs" />
4920- <Compile Include="Runner\TcpWriter.cs" />
4921- <Compile Include="Runner\TextUI.cs" />
4922- <Compile Include="SpecialValue.cs" />
4923- <Compile Include="TestCaseData.cs" />
4924- <Compile Include="TestContext.cs" />
4925- <Compile Include="Throws.cs" />
4926- </ItemGroup>
4927- <ItemGroup>
4928- <Folder Include="Properties\" />
4929- </ItemGroup>
4930- <ItemGroup>
4931- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
4932- <Visible>False</Visible>
4933- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
4934- <Install>false</Install>
4935- </BootstrapperPackage>
4936- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
4937- <Visible>False</Visible>
4938- <ProductName>.NET Framework 3.5 SP1</ProductName>
4939- <Install>true</Install>
4940- </BootstrapperPackage>
4941- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
4942- <Visible>False</Visible>
4943- <ProductName>Windows Installer 3.1</ProductName>
4944- <Install>true</Install>
4945- </BootstrapperPackage>
4946- </ItemGroup>
4947- <ItemGroup>
4948- <None Include="nunit.snk" />
4949- </ItemGroup>
4950- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4951+<?xml version="1.0" encoding="utf-8"?>
4952+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
4953+ <PropertyGroup>
4954+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4955+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
4956+ <ProductVersion>9.0.30729</ProductVersion>
4957+ <SchemaVersion>2.0</SchemaVersion>
4958+ <ProjectGuid>{D12F0F7B-8DE3-43EC-BA49-41052D065A9B}</ProjectGuid>
4959+ <OutputType>Library</OutputType>
4960+ <AppDesignerFolder>Properties</AppDesignerFolder>
4961+ <RootNamespace>NUnitLite</RootNamespace>
4962+ <AssemblyName>nunitlite</AssemblyName>
4963+ <FileUpgradeFlags>
4964+ </FileUpgradeFlags>
4965+ <OldToolsVersion>3.5</OldToolsVersion>
4966+ <UpgradeBackupLocation>
4967+ </UpgradeBackupLocation>
4968+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
4969+ <PublishUrl>publish\</PublishUrl>
4970+ <Install>true</Install>
4971+ <InstallFrom>Disk</InstallFrom>
4972+ <UpdateEnabled>false</UpdateEnabled>
4973+ <UpdateMode>Foreground</UpdateMode>
4974+ <UpdateInterval>7</UpdateInterval>
4975+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
4976+ <UpdatePeriodically>false</UpdatePeriodically>
4977+ <UpdateRequired>false</UpdateRequired>
4978+ <MapFileExtensions>true</MapFileExtensions>
4979+ <ApplicationRevision>0</ApplicationRevision>
4980+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
4981+ <IsWebBootstrapper>false</IsWebBootstrapper>
4982+ <UseApplicationTrust>false</UseApplicationTrust>
4983+ <BootstrapperEnabled>true</BootstrapperEnabled>
4984+ <TargetFrameworkProfile />
4985+ <IntermediateOutputPath>obj\$(Configuration)\net-4.5\</IntermediateOutputPath>
4986+ </PropertyGroup>
4987+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
4988+ <DebugSymbols>true</DebugSymbols>
4989+ <DebugType>full</DebugType>
4990+ <Optimize>false</Optimize>
4991+ <OutputPath>..\..\bin\Debug\net-4.5\</OutputPath>
4992+ <DefineConstants>TRACE;DEBUG;NET_4_5, CLR_4_0,NUNITLITE</DefineConstants>
4993+ <ErrorReport>prompt</ErrorReport>
4994+ <WarningLevel>4</WarningLevel>
4995+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
4996+ <DocumentationFile>..\..\bin\Debug\net-4.5\nunitlite.xml</DocumentationFile>
4997+ <Prefer32Bit>false</Prefer32Bit>
4998+ </PropertyGroup>
4999+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
5000+ <DebugType>pdbonly</DebugType>
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches