public void RerunFixtureAfterTearDownFixed() 
        {
            MisbehavingFixture fixture = new MisbehavingFixture();
            fixture.blowUpInTearDown = true;
            ITestResult result = TestBuilder.RunTestFixture(fixture);
            Assert.AreEqual(1, result.Children.Count);

            fixture.Reinitialize();
            result = TestBuilder.RunTestFixture(fixture);

            Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" );
            Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" );
        }
        public void HandleErrorInFixtureTearDownAfterErrorInFixtureSetUp()
        {
            MisbehavingFixture fixture = new MisbehavingFixture();
            fixture.blowUpInSetUp = true;
            fixture.blowUpInTearDown = true;
            ITestResult result = TestBuilder.RunTestFixture(fixture);
            Assert.AreEqual(1, result.Children.Count);
            Assert.AreEqual(ResultState.Error, result.ResultState);

            Assert.AreEqual(1, fixture.setUpCount, "setUpCount");
            Assert.AreEqual(1, fixture.tearDownCount, "tearDownCOunt");

            Assert.AreEqual("System.Exception : This was thrown from fixture setup" + Env.NewLine + 
                "TearDown : System.Exception : This was thrown from fixture teardown", result.Message);
            Assert.That(result.StackTrace, Does.Contain("--TearDown"));
        }
        public void HandleErrorInFixtureSetup() 
        {
            MisbehavingFixture fixture = new MisbehavingFixture();
            fixture.blowUpInSetUp = true;
            ITestResult result = TestBuilder.RunTestFixture(fixture);

            Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" );
            Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" );

            Assert.AreEqual(ResultState.Error, result.ResultState);
            Assert.AreEqual("System.Exception : This was thrown from fixture setup", result.Message, "TestSuite Message");
            Assert.IsNotNull(result.StackTrace, "TestSuite StackTrace should not be null");

            Assert.AreEqual(1, result.Children.Count, "Child result count");
            Assert.AreEqual(1, result.FailCount, "Failure count");
        }
        public void RerunFixtureAfterSetUpFixed() 
        {
            MisbehavingFixture fixture = new MisbehavingFixture();
            fixture.blowUpInSetUp = true;
            ITestResult result = TestBuilder.RunTestFixture(fixture);

            Assert.AreEqual(ResultState.Error, result.ResultState);

            //fix the blow up in setup
            fixture.Reinitialize();
            result = TestBuilder.RunTestFixture(fixture);

            Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" );
            Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" );

            Assert.AreEqual(ResultState.Success, result.ResultState);
        }
        public void HandleErrorInFixtureTearDownAfterErrorInTest()
        {
            MisbehavingFixture fixture = new MisbehavingFixture();
            fixture.blowUpInTest = true;
            fixture.blowUpInTearDown = true;
            ITestResult result = TestBuilder.RunTestFixture(fixture);
            Assert.AreEqual(1, result.Children.Count());
            Assert.AreEqual(ResultState.TearDownError, result.ResultState);

            Assert.AreEqual(1, fixture.setUpCount, "setUpCount");
            Assert.AreEqual(1, fixture.tearDownCount, "tearDownCount");

            Assert.AreEqual(TestResult.CHILD_ERRORS_MESSAGE + Env.NewLine + "TearDown : System.Exception : This was thrown from fixture teardown", result.Message);
            Assert.That(result.ResultState.Site, Is.EqualTo(FailureSite.TearDown));
            Assert.That(result.StackTrace, Does.Contain("--TearDown"));
        }