~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/tests/mock-assembly/MockAssembly.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ****************************************************************
2
 
// This is free software licensed under the NUnit license. You
3
 
// may obtain a copy of the license as well as information regarding
4
 
// copyright ownership at http://nunit.org.
5
 
// ****************************************************************
6
 
using System;
7
 
using NUnit.Framework;
8
 
using NUnit.Core;
9
 
 
10
 
namespace NUnit.Tests
11
 
{
12
 
        namespace Assemblies
13
 
        {
14
 
                /// <summary>
15
 
                /// Constant definitions for the mock-assembly dll.
16
 
                /// </summary>
17
 
                public class MockAssembly
18
 
        {
19
 
#if CLR_2_0 || CLR_4_0
20
 
            public static int Classes = 9;
21
 
#else
22
 
            public static int Classes = 8;
23
 
#endif
24
 
            public static int NamespaceSuites = 6; // assembly, NUnit, Tests, Assemblies, Singletons, TestAssembly
25
 
 
26
 
                        public static int Tests = MockTestFixture.Tests 
27
 
                                                + Singletons.OneTestCase.Tests 
28
 
                                                + TestAssembly.MockTestFixture.Tests 
29
 
                                                + IgnoredFixture.Tests
30
 
                                                + ExplicitFixture.Tests
31
 
                                                + BadFixture.Tests
32
 
                                                + FixtureWithTestCases.Tests
33
 
                                                + ParameterizedFixture.Tests
34
 
                                                + GenericFixtureConstants.Tests;
35
 
                        
36
 
            public static int Suites = MockTestFixture.Suites 
37
 
                                                + Singletons.OneTestCase.Suites
38
 
                                                + TestAssembly.MockTestFixture.Suites 
39
 
                                                + IgnoredFixture.Suites
40
 
                                                + ExplicitFixture.Suites
41
 
                                                + BadFixture.Suites
42
 
                                                + FixtureWithTestCases.Suites
43
 
                                                + ParameterizedFixture.Suites
44
 
                                                + GenericFixtureConstants.Suites
45
 
                                                + NamespaceSuites;
46
 
                        
47
 
                        public static readonly int Nodes = Tests + Suites;
48
 
                        
49
 
                        public static int ExplicitFixtures = 1;
50
 
                        public static int SuitesRun = Suites - ExplicitFixtures;
51
 
 
52
 
                        public static int Ignored = MockTestFixture.Ignored + IgnoredFixture.Tests;
53
 
                        public static int Explicit = MockTestFixture.Explicit + ExplicitFixture.Tests;
54
 
                        public static int NotRunnable = MockTestFixture.NotRunnable + BadFixture.Tests;
55
 
                        public static int NotRun = Ignored + Explicit + NotRunnable;
56
 
                    public static int TestsRun = Tests - NotRun;
57
 
                        public static int ResultCount = Tests - Explicit;
58
 
 
59
 
                        public static int Errors = MockTestFixture.Errors;
60
 
            public static int Failures = MockTestFixture.Failures;
61
 
                        public static int ErrorsAndFailures = Errors + Failures;
62
 
 
63
 
                        public static int Categories = MockTestFixture.Categories;
64
 
 
65
 
            public static string AssemblyPath = AssemblyHelper.GetAssemblyPath(typeof(MockAssembly));
66
 
                }
67
 
 
68
 
                public class MockSuite
69
 
                {
70
 
                        [Suite]
71
 
                        public static TestSuite Suite
72
 
                        {
73
 
                                get
74
 
                                {
75
 
                                        return new TestSuite( "MockSuite" );
76
 
                                }
77
 
                        }
78
 
                }
79
 
 
80
 
                [TestFixture(Description="Fake Test Fixture")]
81
 
                [Category("FixtureCategory")]
82
 
                public class MockTestFixture
83
 
                {
84
 
                        public static readonly int Tests = 11;
85
 
                        public static readonly int Suites = 1;
86
 
 
87
 
                        public static readonly int Ignored = 1;
88
 
                        public static readonly int Explicit = 1;
89
 
                        public static readonly int NotRunnable = 2;
90
 
                        public static readonly int NotRun = Ignored + Explicit + NotRunnable;
91
 
                    public static readonly int TestsRun = Tests - NotRun;
92
 
                        public static readonly int ResultCount = Tests - Explicit;
93
 
 
94
 
            public static readonly int Failures = 1;
95
 
            public static readonly int Errors = 1;
96
 
                        public static readonly int ErrorsAndFailures = Errors + Failures;
97
 
 
98
 
                        public static readonly int Categories = 5;
99
 
                    public static readonly int MockCategoryTests = 2;
100
 
 
101
 
                        [Test(Description="Mock Test #1")]
102
 
                        public void MockTest1()
103
 
                        {}
104
 
 
105
 
                        [Test]
106
 
                        [Category("MockCategory")]
107
 
                        [Property("Severity","Critical")]
108
 
            [Description("This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really long description")]
109
 
            public void MockTest2()
110
 
                        {}
111
 
 
112
 
                        [Test]
113
 
                        [Category("MockCategory")]
114
 
                        [Category("AnotherCategory")]
115
 
                        public void MockTest3()
116
 
            { Assert.Pass("Succeeded!"); }
117
 
 
118
 
            [Test]
119
 
            protected static void MockTest5()
120
 
            {}
121
 
 
122
 
            [Test]
123
 
            public void FailingTest()
124
 
            {
125
 
                Assert.Fail("Intentional failure");
126
 
            }
127
 
 
128
 
                    [Test, Property("TargetMethod", "SomeClassName"), Property("Size", 5), /*Property("TargetType", typeof( System.Threading.Thread ))*/]
129
 
                        public void TestWithManyProperties()
130
 
                        {}
131
 
 
132
 
                        [Test]
133
 
                        [Ignore("ignoring this test method for now")]
134
 
                        [Category("Foo")]
135
 
                        public void MockTest4()
136
 
                        {}
137
 
 
138
 
                        [Test, Explicit]
139
 
                        [Category( "Special" )]
140
 
                        public void ExplicitlyRunTest()
141
 
                        {}
142
 
 
143
 
                        [Test]
144
 
                        public void NotRunnableTest( int a, int b)
145
 
                        {
146
 
                        }
147
 
 
148
 
            [Test]
149
 
            public void InconclusiveTest()
150
 
            {
151
 
                Assert.Inconclusive("No valid data");
152
 
            }
153
 
 
154
 
            [Test]
155
 
            public void TestWithException()
156
 
            {
157
 
                MethodThrowsException();
158
 
            }
159
 
 
160
 
            private void MethodThrowsException()
161
 
            {
162
 
                throw new ApplicationException("Intentional Exception");
163
 
            }
164
 
                }
165
 
        }
166
 
 
167
 
        namespace Singletons
168
 
        {
169
 
                [TestFixture]
170
 
                public class OneTestCase
171
 
                {
172
 
                        public static readonly int Tests = 1;
173
 
                        public static readonly int Suites = 1;          
174
 
 
175
 
                        [Test]
176
 
                        public virtual void TestCase() 
177
 
                        {}
178
 
                }
179
 
        }
180
 
 
181
 
        namespace TestAssembly
182
 
        {
183
 
                [TestFixture]
184
 
                public class MockTestFixture
185
 
                {
186
 
                        public static readonly int Tests = 1;
187
 
                        public static readonly int Suites = 1;
188
 
 
189
 
                        [Test]
190
 
                        public void MyTest()
191
 
                        {
192
 
                        }
193
 
                }
194
 
        }
195
 
 
196
 
        [TestFixture, Ignore]
197
 
        public class IgnoredFixture
198
 
        {
199
 
                public static readonly int Tests = 3;
200
 
                public static readonly int Suites = 1;
201
 
 
202
 
                [Test]
203
 
                public void Test1() { }
204
 
 
205
 
                [Test]
206
 
                public void Test2() { }
207
 
                
208
 
                [Test]
209
 
                public void Test3() { }
210
 
        }
211
 
 
212
 
        [TestFixture,Explicit]
213
 
        public class ExplicitFixture
214
 
        {
215
 
                public static readonly int Tests = 2;
216
 
                public static readonly int Suites = 1;
217
 
        public static readonly int Nodes = Tests + Suites;
218
 
 
219
 
                [Test]
220
 
                public void Test1() { }
221
 
 
222
 
                [Test]
223
 
                public void Test2() { }
224
 
        }
225
 
 
226
 
        [TestFixture]
227
 
        public class BadFixture
228
 
        {
229
 
                public static readonly int Tests = 1;
230
 
                public static readonly int Suites = 1;
231
 
 
232
 
                public BadFixture(int val) { }
233
 
 
234
 
                [Test]
235
 
                public void SomeTest() { }
236
 
        }
237
 
        
238
 
        [TestFixture]
239
 
        public class FixtureWithTestCases
240
 
    {
241
 
#if CLR_2_0 || CLR_4_0
242
 
        public static readonly int Tests = 4;
243
 
                public static readonly int Suites = 3;
244
 
#else
245
 
                public static readonly int Tests = 2;
246
 
                public static readonly int Suites = 2;
247
 
#endif
248
 
                
249
 
                [TestCase(2, 2, Result=4)]
250
 
                [TestCase(9, 11, Result=20)]
251
 
                public int MethodWithParameters(int x, int y)
252
 
                {
253
 
                        return x+y;
254
 
        }
255
 
 
256
 
#if CLR_2_0 || CLR_4_0
257
 
        [TestCase(2, 4)]
258
 
                [TestCase(9.2, 11.7)]
259
 
                public void GenericMethod<T>(T x, T y)
260
 
                {
261
 
                }
262
 
#endif
263
 
        }
264
 
        
265
 
        [TestFixture(5)]
266
 
        [TestFixture(42)]
267
 
        public class ParameterizedFixture
268
 
        {
269
 
                public static readonly int Tests = 4;
270
 
                public static readonly int Suites = 3;
271
 
 
272
 
                public ParameterizedFixture(int num) { }
273
 
                
274
 
                [Test]
275
 
                public void Test1() { }
276
 
                
277
 
                [Test]
278
 
                public void Test2() { }
279
 
        }
280
 
        
281
 
        public class GenericFixtureConstants
282
 
    {
283
 
#if CLR_2_0 || CLR_4_0
284
 
        public static readonly int Tests = 4;
285
 
                public static readonly int Suites = 3;
286
 
#else
287
 
        public static readonly int Tests = 0;
288
 
        public static readonly int Suites = 0;
289
 
#endif
290
 
    }
291
 
 
292
 
#if CLR_2_0 || CLR_4_0
293
 
    [TestFixture(5)]
294
 
        [TestFixture(11.5)]
295
 
        public class GenericFixture<T>
296
 
        {
297
 
                public GenericFixture(T num){ }
298
 
                
299
 
                [Test]
300
 
                public void Test1() { }
301
 
                
302
 
                [Test]
303
 
                public void Test2() { }
304
 
        }
305
 
#endif
306
 
}
 
1
// ****************************************************************
 
2
// This is free software licensed under the NUnit license. You
 
3
// may obtain a copy of the license as well as information regarding
 
4
// copyright ownership at http://nunit.org.
 
5
// ****************************************************************
 
6
using System;
 
7
using NUnit.Framework;
 
8
using NUnit.Core;
 
9
 
 
10
namespace NUnit.Tests
 
11
{
 
12
        namespace Assemblies
 
13
        {
 
14
                /// <summary>
 
15
                /// Constant definitions for the mock-assembly dll.
 
16
                /// </summary>
 
17
                public class MockAssembly
 
18
        {
 
19
#if CLR_2_0 || CLR_4_0
 
20
            public static int Classes = 9;
 
21
#else
 
22
            public static int Classes = 8;
 
23
#endif
 
24
            public static int NamespaceSuites = 6; // assembly, NUnit, Tests, Assemblies, Singletons, TestAssembly
 
25
 
 
26
                        public static int Tests = MockTestFixture.Tests 
 
27
                                                + Singletons.OneTestCase.Tests 
 
28
                                                + TestAssembly.MockTestFixture.Tests 
 
29
                                                + IgnoredFixture.Tests
 
30
                                                + ExplicitFixture.Tests
 
31
                                                + BadFixture.Tests
 
32
                                                + FixtureWithTestCases.Tests
 
33
                                                + ParameterizedFixture.Tests
 
34
                                                + GenericFixtureConstants.Tests;
 
35
                        
 
36
            public static int Suites = MockTestFixture.Suites 
 
37
                                                + Singletons.OneTestCase.Suites
 
38
                                                + TestAssembly.MockTestFixture.Suites 
 
39
                                                + IgnoredFixture.Suites
 
40
                                                + ExplicitFixture.Suites
 
41
                                                + BadFixture.Suites
 
42
                                                + FixtureWithTestCases.Suites
 
43
                                                + ParameterizedFixture.Suites
 
44
                                                + GenericFixtureConstants.Suites
 
45
                                                + NamespaceSuites;
 
46
                        
 
47
                        public static readonly int Nodes = Tests + Suites;
 
48
                        
 
49
                        public static int ExplicitFixtures = 1;
 
50
                        public static int SuitesRun = Suites - ExplicitFixtures;
 
51
 
 
52
                        public static int Ignored = MockTestFixture.Ignored + IgnoredFixture.Tests;
 
53
                        public static int Explicit = MockTestFixture.Explicit + ExplicitFixture.Tests;
 
54
                        public static int NotRunnable = MockTestFixture.NotRunnable + BadFixture.Tests;
 
55
                        public static int NotRun = Ignored + Explicit + NotRunnable;
 
56
                    public static int TestsRun = Tests - NotRun;
 
57
                        public static int ResultCount = Tests - Explicit;
 
58
 
 
59
                        public static int Errors = MockTestFixture.Errors;
 
60
            public static int Failures = MockTestFixture.Failures;
 
61
 
 
62
                        public static int Categories = MockTestFixture.Categories;
 
63
 
 
64
            public static string AssemblyPath = AssemblyHelper.GetAssemblyPath(typeof(MockAssembly));
 
65
                }
 
66
 
 
67
                public class MockSuite
 
68
                {
 
69
                        [Suite]
 
70
                        public static TestSuite Suite
 
71
                        {
 
72
                                get
 
73
                                {
 
74
                                        return new TestSuite( "MockSuite" );
 
75
                                }
 
76
                        }
 
77
                }
 
78
 
 
79
                [TestFixture(Description="Fake Test Fixture")]
 
80
                [Category("FixtureCategory")]
 
81
                public class MockTestFixture
 
82
                {
 
83
                        public static readonly int Tests = 11;
 
84
                        public static readonly int Suites = 1;
 
85
 
 
86
                        public static readonly int Ignored = 1;
 
87
                        public static readonly int Explicit = 1;
 
88
                        public static readonly int NotRunnable = 2;
 
89
                        public static readonly int NotRun = Ignored + Explicit + NotRunnable;
 
90
                    public static readonly int TestsRun = Tests - NotRun;
 
91
                        public static readonly int ResultCount = Tests - Explicit;
 
92
 
 
93
            public static readonly int Failures = 1;
 
94
            public static readonly int Errors = 1;
 
95
 
 
96
                        public static readonly int Categories = 5;
 
97
                    public static readonly int MockCategoryTests = 2;
 
98
 
 
99
                        [Test(Description="Mock Test #1")]
 
100
                        public void MockTest1()
 
101
                        {}
 
102
 
 
103
                        [Test]
 
104
                        [Category("MockCategory")]
 
105
                        [Property("Severity","Critical")]
 
106
            [Description("This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really long description")]
 
107
            public void MockTest2()
 
108
                        {}
 
109
 
 
110
                        [Test]
 
111
                        [Category("MockCategory")]
 
112
                        [Category("AnotherCategory")]
 
113
                        public void MockTest3()
 
114
            { Assert.Pass("Succeeded!"); }
 
115
 
 
116
            [Test]
 
117
            protected static void MockTest5()
 
118
            {}
 
119
 
 
120
            [Test]
 
121
            public void FailingTest()
 
122
            {
 
123
                Assert.Fail("Intentional failure");
 
124
            }
 
125
 
 
126
                    [Test, Property("TargetMethod", "SomeClassName"), Property("Size", 5), /*Property("TargetType", typeof( System.Threading.Thread ))*/]
 
127
                        public void TestWithManyProperties()
 
128
                        {}
 
129
 
 
130
                        [Test]
 
131
                        [Ignore("ignoring this test method for now")]
 
132
                        [Category("Foo")]
 
133
                        public void MockTest4()
 
134
                        {}
 
135
 
 
136
                        [Test, Explicit]
 
137
                        [Category( "Special" )]
 
138
                        public void ExplicitlyRunTest()
 
139
                        {}
 
140
 
 
141
                        [Test]
 
142
                        public void NotRunnableTest( int a, int b)
 
143
                        {
 
144
                        }
 
145
 
 
146
            [Test]
 
147
            public void InconclusiveTest()
 
148
            {
 
149
                Assert.Inconclusive("No valid data");
 
150
            }
 
151
 
 
152
            [Test]
 
153
            public void TestWithException()
 
154
            {
 
155
                MethodThrowsException();
 
156
            }
 
157
 
 
158
            private void MethodThrowsException()
 
159
            {
 
160
                throw new ApplicationException("Intentional Exception");
 
161
            }
 
162
                }
 
163
        }
 
164
 
 
165
        namespace Singletons
 
166
        {
 
167
                [TestFixture]
 
168
                public class OneTestCase
 
169
                {
 
170
                        public static readonly int Tests = 1;
 
171
                        public static readonly int Suites = 1;          
 
172
 
 
173
                        [Test]
 
174
                        public virtual void TestCase() 
 
175
                        {}
 
176
                }
 
177
        }
 
178
 
 
179
        namespace TestAssembly
 
180
        {
 
181
                [TestFixture]
 
182
                public class MockTestFixture
 
183
                {
 
184
                        public static readonly int Tests = 1;
 
185
                        public static readonly int Suites = 1;
 
186
 
 
187
                        [Test]
 
188
                        public void MyTest()
 
189
                        {
 
190
                        }
 
191
                }
 
192
        }
 
193
 
 
194
        [TestFixture, Ignore]
 
195
        public class IgnoredFixture
 
196
        {
 
197
                public static readonly int Tests = 3;
 
198
                public static readonly int Suites = 1;
 
199
 
 
200
                [Test]
 
201
                public void Test1() { }
 
202
 
 
203
                [Test]
 
204
                public void Test2() { }
 
205
                
 
206
                [Test]
 
207
                public void Test3() { }
 
208
        }
 
209
 
 
210
        [TestFixture,Explicit]
 
211
        public class ExplicitFixture
 
212
        {
 
213
                public static readonly int Tests = 2;
 
214
                public static readonly int Suites = 1;
 
215
        public static readonly int Nodes = Tests + Suites;
 
216
 
 
217
                [Test]
 
218
                public void Test1() { }
 
219
 
 
220
                [Test]
 
221
                public void Test2() { }
 
222
        }
 
223
 
 
224
        [TestFixture]
 
225
        public class BadFixture
 
226
        {
 
227
                public static readonly int Tests = 1;
 
228
                public static readonly int Suites = 1;
 
229
 
 
230
                public BadFixture(int val) { }
 
231
 
 
232
                [Test]
 
233
                public void SomeTest() { }
 
234
        }
 
235
        
 
236
        [TestFixture]
 
237
        public class FixtureWithTestCases
 
238
    {
 
239
#if CLR_2_0 || CLR_4_0
 
240
        public static readonly int Tests = 4;
 
241
                public static readonly int Suites = 3;
 
242
#else
 
243
                public static readonly int Tests = 2;
 
244
                public static readonly int Suites = 2;
 
245
#endif
 
246
                
 
247
                [TestCase(2, 2, Result=4)]
 
248
                [TestCase(9, 11, Result=20)]
 
249
                public int MethodWithParameters(int x, int y)
 
250
                {
 
251
                        return x+y;
 
252
        }
 
253
 
 
254
#if CLR_2_0 || CLR_4_0
 
255
        [TestCase(2, 4)]
 
256
                [TestCase(9.2, 11.7)]
 
257
                public void GenericMethod<T>(T x, T y)
 
258
                {
 
259
                }
 
260
#endif
 
261
        }
 
262
        
 
263
        [TestFixture(5)]
 
264
        [TestFixture(42)]
 
265
        public class ParameterizedFixture
 
266
        {
 
267
                public static readonly int Tests = 4;
 
268
                public static readonly int Suites = 3;
 
269
 
 
270
                public ParameterizedFixture(int num) { }
 
271
                
 
272
                [Test]
 
273
                public void Test1() { }
 
274
                
 
275
                [Test]
 
276
                public void Test2() { }
 
277
        }
 
278
        
 
279
        public class GenericFixtureConstants
 
280
    {
 
281
#if CLR_2_0 || CLR_4_0
 
282
        public static readonly int Tests = 4;
 
283
                public static readonly int Suites = 3;
 
284
#else
 
285
        public static readonly int Tests = 0;
 
286
        public static readonly int Suites = 0;
 
287
#endif
 
288
    }
 
289
 
 
290
#if CLR_2_0 || CLR_4_0
 
291
    [TestFixture(5)]
 
292
        [TestFixture(11.5)]
 
293
        public class GenericFixture<T>
 
294
        {
 
295
                public GenericFixture(T num){ }
 
296
                
 
297
                [Test]
 
298
                public void Test1() { }
 
299
                
 
300
                [Test]
 
301
                public void Test2() { }
 
302
        }
 
303
#endif
 
304
}