1 // *********************************************************************** 2 // Copyright (c) 2007 Charlie Poole 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining 5 // a copy of this software and associated documentation files (the 6 // "Software"), to deal in the Software without restriction, including 7 // without limitation the rights to use, copy, modify, merge, publish, 8 // distribute, sublicense, and/or sell copies of the Software, and to 9 // permit persons to whom the Software is furnished to do so, subject to 10 // the following conditions: 11 // 12 // The above copyright notice and this permission notice shall be 13 // included in all copies or substantial portions of the Software. 14 // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 // *********************************************************************** 23 #if false 24 using System; 25 using System.Reflection; 26 using NUnit.Framework.Api; 27 using NUnit.Framework.Internal; 28 using NUnit.TestData.RepeatedTestFixture; 29 using NUnit.TestUtilities; 30 31 namespace NUnit.Framework.Attributes 32 { 33 [TestFixture] 34 public class RepeatedTestTests 35 { 36 private MethodInfo successMethod; 37 private MethodInfo failOnFirstMethod; 38 private MethodInfo failOnThirdMethod; 39 40 [SetUp] SetUp()41 public void SetUp() 42 { 43 Type testType = typeof(RepeatSuccessFixture); 44 successMethod = testType.GetMethod ("RepeatSuccess"); 45 testType = typeof(RepeatFailOnFirstFixture); 46 failOnFirstMethod = testType.GetMethod("RepeatFailOnFirst"); 47 testType = typeof(RepeatFailOnThirdFixture); 48 failOnThirdMethod = testType.GetMethod("RepeatFailOnThird"); 49 } 50 51 [Test] RepeatSuccess()52 public void RepeatSuccess() 53 { 54 Assert.IsNotNull (successMethod); 55 RepeatSuccessFixture fixture = new RepeatSuccessFixture(); 56 ITestResult result = TestBuilder.RunTestFixture(fixture); 57 58 Assert.IsTrue(result.ResultState == ResultState.Success); 59 Assert.AreEqual(1, fixture.FixtureSetupCount); 60 Assert.AreEqual(1, fixture.FixtureTeardownCount); 61 Assert.AreEqual(3, fixture.SetupCount); 62 Assert.AreEqual(3, fixture.TeardownCount); 63 Assert.AreEqual(3, fixture.Count); 64 } 65 66 [Test] RepeatFailOnFirst()67 public void RepeatFailOnFirst() 68 { 69 Assert.IsNotNull (failOnFirstMethod); 70 RepeatFailOnFirstFixture fixture = new RepeatFailOnFirstFixture(); 71 ITestResult result = TestBuilder.RunTestFixture(fixture); 72 73 Assert.IsFalse(result.ResultState == ResultState.Success); 74 Assert.AreEqual(1, fixture.SetupCount); 75 Assert.AreEqual(1, fixture.TeardownCount); 76 Assert.AreEqual(1, fixture.Count); 77 } 78 79 [Test] RepeatFailOnThird()80 public void RepeatFailOnThird() 81 { 82 Assert.IsNotNull (failOnThirdMethod); 83 RepeatFailOnThirdFixture fixture = new RepeatFailOnThirdFixture(); 84 ITestResult result = TestBuilder.RunTestFixture(fixture); 85 86 Assert.IsFalse(result.ResultState == ResultState.Success); 87 Assert.AreEqual(3, fixture.SetupCount); 88 Assert.AreEqual(3, fixture.TeardownCount); 89 Assert.AreEqual(3, fixture.Count); 90 } 91 92 [Test] IgnoreWorksWithRepeatedTest()93 public void IgnoreWorksWithRepeatedTest() 94 { 95 RepeatedTestWithIgnore fixture = new RepeatedTestWithIgnore(); 96 TestBuilder.RunTestFixture(fixture); 97 98 Assert.AreEqual( 0, fixture.SetupCount ); 99 Assert.AreEqual( 0, fixture.TeardownCount ); 100 Assert.AreEqual( 0, fixture.Count ); 101 } 102 103 [Test] CategoryWorksWithRepeatedTest()104 public void CategoryWorksWithRepeatedTest() 105 { 106 TestSuite suite = TestBuilder.MakeFixture(typeof(RepeatedTestWithCategory)); 107 Test test = suite.Tests[0] as Test; 108 System.Collections.IList categories = test.Properties["Category"]; 109 Assert.IsNotNull(categories); 110 Assert.AreEqual(1, categories.Count); 111 Assert.AreEqual("SAMPLE", categories[0]); 112 } 113 } 114 } 115 #endif