コード例 #1
0
        public void ChildClassWithLifeCycleShouldOverrideLifeCycle()
        {
            var         fixture = TestBuilder.MakeFixture(typeof(LifeCycleInheritanceOverriddenFixture));
            ITestResult result  = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifySingleInstance(2);
        }
コード例 #2
0
        public void BaseLifecycleFromOtherAssemblyShouldOverrideAssemblyLevelLifeCycle()
        {
            var asm = TestAssemblyHelper.GenerateInMemoryAssembly(
                InheritedOverrideTest.InheritClassWithOtherLifecycleFromOtherAssembly,
                new[] { typeof(Test).Assembly.Location, typeof(BaseLifeCycle).Assembly.Location });
            var testType = asm.GetType("FixtureUnderTest");
            var fixture  = TestBuilder.MakeFixture(testType);

            ITestResult result = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifySingleInstance(2);
        }
コード例 #3
0
        public void OuterFixtureLevelLifeCycleShouldOverrideAssemblyLevelLifeCycleInNestedFixture()
        {
            var asm = TestAssemblyHelper.GenerateInMemoryAssembly(
                NestedOverrideAssemblyLevelFixtureLifeCycleTest.OuterClass,
                new[] { typeof(Test).Assembly.Location, typeof(BaseLifeCycle).Assembly.Location });
            var testType = asm.GetType("FixtureUnderTest+NestedFixture");
            var fixture  = TestBuilder.MakeFixture(testType);

            ITestResult result = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifySingleInstance(2);
        }
コード例 #4
0
        public void SingleInstanceFullLifeCycleTest()
        {
            BaseLifeCycle.Reset();
            var fixture = TestBuilder.MakeFixture(typeof(FullLifecycleTestCase));
            var attr    = new FixtureLifeCycleAttribute(LifeCycle.SingleInstance);

            attr.ApplyToTest(fixture);

            ITestResult result = TestBuilder.RunTest(fixture);

            Assert.That(
                result.Children.Select(t => t.ResultState),
                Is.EquivalentTo(new[] { ResultState.Success, ResultState.Failure, ResultState.Failure }));

            BaseLifeCycle.VerifySingleInstance(3);
        }