Exemplo n.º 1
0
 public void HandleExceptionInBothSetUpAndTearDown()
 {
     Exception e1 = new Exception("Test message for exception thrown from setup");
     Exception e2 = new Exception("Test message for exception thrown from tear down");
     SetupAndTearDownExceptionFixture fixture = new SetupAndTearDownExceptionFixture();
     fixture.setupException = e1;
     fixture.tearDownException = e2;
     ITestResult suiteResult = TestBuilder.RunTestFixture(fixture);
     Assert.That(suiteResult.HasChildren, "Fixture test should have child result.");
     ITestResult result = suiteResult.Children.ToArray()[0];
     Assert.AreEqual(ResultState.Error, result.ResultState, "Test should be in error state");
     string expected = string.Format("{0} : {1}", e1.GetType().FullName, e1.Message) + Environment.NewLine
         + string.Format("TearDown : {0} : {1}", e2.GetType().FullName, e2.Message);
     Assert.AreEqual(expected, result.Message);
     Assert.That(result.StackTrace, Does.Contain("--TearDown"));
     Assert.That(result.StackTrace, Does.Contain(fixture.GetType().FullName)); // Sanity check
 }
 public void HandleExceptionInTearDown()
 {
     Exception e = new Exception("Test message for exception thrown from tear down");
     SetupAndTearDownExceptionFixture fixture = new SetupAndTearDownExceptionFixture();
     fixture.tearDownException = e;
     ITestResult suiteResult = TestBuilder.RunTestFixture(fixture);
     Assert.That(suiteResult.HasChildren, "Fixture test should have child result.");
     ITestResult result = suiteResult.Children[0];
     Assert.AreEqual(result.ResultState, ResultState.Error, "Test should be in error state");
     string expected = string.Format("TearDown : {0} : {1}", e.GetType().FullName, e.Message);
     Assert.AreEqual(expected, result.Message);
     Assert.That(result.StackTrace, Is.StringStarting("--TearDown"));
     Assert.That(result.StackTrace, Contains.Substring(fixture.GetType().FullName)); // Sanity check
 }
Exemplo n.º 3
0
 public void HandleExceptionInSetUp()
 {
     Exception e = new Exception("Test message for exception thrown from setup");
     SetupAndTearDownExceptionFixture fixture = new SetupAndTearDownExceptionFixture();
     fixture.setupException = e;
     ITestResult suiteResult = TestBuilder.RunTestFixture(fixture);
     Assert.IsTrue(suiteResult.HasChildren, "Fixture test should have child result.");
     TestResult result = (TestResult)suiteResult.Children.ToArray()[0];
     Assert.AreEqual(ResultState.Error, result.ResultState, "Test should be in error state");
     string expected = string.Format("{0} : {1}", e.GetType().FullName, e.Message);
     Assert.AreEqual(expected, result.Message);
     Assert.That(result.StackTrace, Does.Contain(fixture.GetType().FullName)); // Sanity check
 }
Exemplo n.º 4
0
 public void TearDownRecordsOriginalExceptionThownByTestCase()
 {
     Exception e = new Exception("Test message for exception thrown from tear down");
     SetupAndTearDownExceptionFixture fixture = new SetupAndTearDownExceptionFixture();
     fixture.tearDownException = e;
     TestResult suiteResult = TestBuilder.RunTestFixture(fixture);
     Assert.That(suiteResult.HasChildren, "Fixture test should have child result.");
     TestResult result = (TestResult)suiteResult.Children[0];
     Assert.AreEqual(result.ResultState, ResultState.Error, "Test should be in error state");
     string expected = string.Format("TearDown : {0} : {1}", e.GetType().FullName, e.Message);
     Assert.AreEqual(expected, result.Message);
 }