1
// ****************************************************************
2
// Copyright 2007, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org
5
// ****************************************************************
10
namespace NUnit.TestData.FixtureSetUpTearDown
13
public class SetUpAndTearDownFixture
15
public int setUpCount = 0;
16
public int tearDownCount = 0;
19
public virtual void Init()
25
public virtual void Destroy()
31
public void Success() { }
34
public void EvenMoreSuccess() { }
37
[TestFixture, Explicit]
38
public class ExplicitSetUpAndTearDownFixture
40
public int setUpCount = 0;
41
public int tearDownCount = 0;
44
public virtual void Init()
50
public virtual void Destroy()
56
public void Success(){}
59
public void EvenMoreSuccess(){}
63
public class InheritSetUpAndTearDown : SetUpAndTearDownFixture
66
public void AnotherTest(){}
69
public void YetAnotherTest(){}
73
public class DefineInheritSetUpAndTearDown : SetUpAndTearDownFixture
75
public int derivedSetUpCount;
76
public int derivedTearDownCount;
79
public override void Init()
85
public override void Destroy()
87
derivedTearDownCount++;
91
public void AnotherTest() { }
94
public void YetAnotherTest() { }
98
public class DerivedSetUpAndTearDownFixture : SetUpAndTearDownFixture
100
public int derivedSetUpCount;
101
public int derivedTearDownCount;
103
public bool baseSetUpCalledFirst;
104
public bool baseTearDownCalledLast;
110
baseSetUpCalledFirst = this.setUpCount > 0;
113
[TestFixtureTearDown]
114
public void Destroy2()
116
derivedTearDownCount++;
117
baseTearDownCalledLast = this.tearDownCount == 0;
121
public void AnotherTest() { }
124
public void YetAnotherTest() { }
128
public class StaticSetUpAndTearDownFixture
130
public static int setUpCount = 0;
131
public static int tearDownCount = 0;
134
public static void Init()
139
[TestFixtureTearDown]
140
public static void Destroy()
147
public class DerivedStaticSetUpAndTearDownFixture : StaticSetUpAndTearDownFixture
149
public static int derivedSetUpCount;
150
public static int derivedTearDownCount;
152
public static bool baseSetUpCalledFirst;
153
public static bool baseTearDownCalledLast;
157
public static void Init2()
160
baseSetUpCalledFirst = setUpCount > 0;
163
[TestFixtureTearDown]
164
public static void Destroy2()
166
derivedTearDownCount++;
167
baseTearDownCalledLast = tearDownCount == 0;
171
#if CLR_2_0 || CLR_4_0
173
public static class StaticClassSetUpAndTearDownFixture
175
public static int setUpCount = 0;
176
public static int tearDownCount = 0;
179
public static void Init()
184
[TestFixtureTearDown]
185
public static void Destroy()
193
public class MisbehavingFixture
195
public bool blowUpInSetUp = false;
196
public bool blowUpInTearDown = false;
198
public int setUpCount = 0;
199
public int tearDownCount = 0;
201
public void Reinitialize()
206
blowUpInSetUp = false;
207
blowUpInTearDown = false;
211
public void BlowUpInSetUp()
215
throw new Exception("This was thrown from fixture setup");
218
[TestFixtureTearDown]
219
public void BlowUpInTearDown()
222
if ( blowUpInTearDown )
223
throw new Exception("This was thrown from fixture teardown");
227
public void nothingToTest()
233
public class ExceptionInConstructor
235
public ExceptionInConstructor()
237
throw new Exception( "This was thrown in constructor" );
241
public void nothingToTest()
247
public class IgnoreInFixtureSetUp
250
public void SetUpCallsIgnore()
252
Assert.Ignore( "TestFixtureSetUp called Ignore" );
256
public void nothingToTest()
262
public class SetUpAndTearDownWithTestInName
264
public int setUpCount = 0;
265
public int tearDownCount = 0;
268
public virtual void TestFixtureSetUp()
273
[TestFixtureTearDown]
274
public virtual void TestFixtureTearDown()
280
public void Success(){}
283
public void EvenMoreSuccess(){}
286
[TestFixture, Ignore( "Do Not Run This" )]
287
public class IgnoredFixture
289
public bool setupCalled = false;
290
public bool teardownCalled = false;
293
public virtual void ShouldNotRun()
298
[TestFixtureTearDown]
299
public virtual void NeitherShouldThis()
301
teardownCalled = true;
305
public void Success(){}
308
public void EvenMoreSuccess(){}
312
public class FixtureWithNoTests
314
public bool setupCalled = false;
315
public bool teardownCalled = false;
318
public virtual void Init()
323
[TestFixtureTearDown]
324
public virtual void Destroy()
326
teardownCalled = true;
331
public class DisposableFixture : IDisposable
333
public bool disposeCalled = false;
336
public void OneTest() { }
338
public void Dispose()
340
disposeCalled = true;
1
// ****************************************************************
2
// Copyright 2007, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org
5
// ****************************************************************
10
namespace NUnit.TestData.FixtureSetUpTearDown
13
public class SetUpAndTearDownFixture
15
public int setUpCount = 0;
16
public int tearDownCount = 0;
19
public virtual void Init()
25
public virtual void Destroy()
31
public void Success() { }
34
public void EvenMoreSuccess() { }
37
[TestFixture, Explicit]
38
public class ExplicitSetUpAndTearDownFixture
40
public int setUpCount = 0;
41
public int tearDownCount = 0;
44
public virtual void Init()
50
public virtual void Destroy()
56
public void Success(){}
59
public void EvenMoreSuccess(){}
63
public class InheritSetUpAndTearDown : SetUpAndTearDownFixture
66
public void AnotherTest(){}
69
public void YetAnotherTest(){}
73
public class DefineInheritSetUpAndTearDown : SetUpAndTearDownFixture
75
public int derivedSetUpCount;
76
public int derivedTearDownCount;
79
public override void Init()
85
public override void Destroy()
87
derivedTearDownCount++;
91
public void AnotherTest() { }
94
public void YetAnotherTest() { }
98
public class DerivedSetUpAndTearDownFixture : SetUpAndTearDownFixture
100
public int derivedSetUpCount;
101
public int derivedTearDownCount;
103
public bool baseSetUpCalledFirst;
104
public bool baseTearDownCalledLast;
110
baseSetUpCalledFirst = this.setUpCount > 0;
113
[TestFixtureTearDown]
114
public void Destroy2()
116
derivedTearDownCount++;
117
baseTearDownCalledLast = this.tearDownCount == 0;
121
public void AnotherTest() { }
124
public void YetAnotherTest() { }
128
public class StaticSetUpAndTearDownFixture
130
public static int setUpCount = 0;
131
public static int tearDownCount = 0;
134
public static void Init()
139
[TestFixtureTearDown]
140
public static void Destroy()
147
public class DerivedStaticSetUpAndTearDownFixture : StaticSetUpAndTearDownFixture
149
public static int derivedSetUpCount;
150
public static int derivedTearDownCount;
152
public static bool baseSetUpCalledFirst;
153
public static bool baseTearDownCalledLast;
157
public static void Init2()
160
baseSetUpCalledFirst = setUpCount > 0;
163
[TestFixtureTearDown]
164
public static void Destroy2()
166
derivedTearDownCount++;
167
baseTearDownCalledLast = tearDownCount == 0;
171
#if CLR_2_0 || CLR_4_0
173
public static class StaticClassSetUpAndTearDownFixture
175
public static int setUpCount = 0;
176
public static int tearDownCount = 0;
179
public static void Init()
184
[TestFixtureTearDown]
185
public static void Destroy()
193
public class MisbehavingFixture
195
public bool blowUpInSetUp = false;
196
public bool blowUpInTearDown = false;
198
public int setUpCount = 0;
199
public int tearDownCount = 0;
201
public void Reinitialize()
206
blowUpInSetUp = false;
207
blowUpInTearDown = false;
211
public void BlowUpInSetUp()
215
throw new Exception("This was thrown from fixture setup");
218
[TestFixtureTearDown]
219
public void BlowUpInTearDown()
222
if ( blowUpInTearDown )
223
throw new Exception("This was thrown from fixture teardown");
227
public void nothingToTest()
233
public class ExceptionInConstructor
235
public ExceptionInConstructor()
237
throw new Exception( "This was thrown in constructor" );
241
public void nothingToTest()
247
public class IgnoreInFixtureSetUp
250
public void SetUpCallsIgnore()
252
Assert.Ignore( "TestFixtureSetUp called Ignore" );
256
public void nothingToTest()
262
public class SetUpAndTearDownWithTestInName
264
public int setUpCount = 0;
265
public int tearDownCount = 0;
268
public virtual void TestFixtureSetUp()
273
[TestFixtureTearDown]
274
public virtual void TestFixtureTearDown()
280
public void Success(){}
283
public void EvenMoreSuccess(){}
286
[TestFixture, Ignore( "Do Not Run This" )]
287
public class IgnoredFixture
289
public bool setupCalled = false;
290
public bool teardownCalled = false;
293
public virtual void ShouldNotRun()
298
[TestFixtureTearDown]
299
public virtual void NeitherShouldThis()
301
teardownCalled = true;
305
public void Success(){}
308
public void EvenMoreSuccess(){}
312
public class FixtureWithNoTests
314
public bool setupCalled = false;
315
public bool teardownCalled = false;
318
public virtual void Init()
323
[TestFixtureTearDown]
324
public virtual void Destroy()
326
teardownCalled = true;
331
public class DisposableFixture : IDisposable
333
public bool disposeCalled = false;
336
public void OneTest() { }
338
public void Dispose()
340
disposeCalled = true;