Esempio n. 1
0
        public void ChildClassWithoutLifeCycleShouldInheritLifeCycle()
        {
            var         fixture = TestBuilder.MakeFixture(typeof(LifeCycleInheritedFixture));
            ITestResult result  = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifyInstancePerTestCase(2);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void InstancePerTestCaseShouldApplyToTheories()
        {
            var         fixture = TestBuilder.MakeFixture(typeof(FixtureWithTheoryTest));
            ITestResult result  = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifyInstancePerTestCase(3);
        }
Esempio n. 4
0
        public void InstancePerTestCaseShouldApplyToParralelTests()
        {
            var fixture = TestBuilder.MakeFixture(typeof(ParallelLifeCycleFixtureInstancePerTestCase));

            ITestResult result = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            BaseLifeCycle.VerifyInstancePerTestCase(3);
        }
Esempio n. 5
0
        public void InstancePerTestCaseShouldApplyToTestFixtureSourceTests()
        {
            var         fixture = TestBuilder.MakeFixture(typeof(LifeCycleWithTestFixtureSourceFixture));
            ITestResult result  = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            // TODO: OneTimeSetUpCount is called twice. Expected? Does seem consistent w/ reusing the class; then there are also two calls.
            BaseLifeCycle.VerifyInstancePerTestCase(4, 2);
        }
Esempio n. 6
0
        public void InstancePerTestCaseShouldApplyToRepeat()
        {
            RepeatingLifeCycleFixtureInstancePerTestCase.RepeatCounter = 0;
            var         fixture = TestBuilder.MakeFixture(typeof(RepeatingLifeCycleFixtureInstancePerTestCase));
            ITestResult result  = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed));
            Assert.AreEqual(3, RepeatingLifeCycleFixtureInstancePerTestCase.RepeatCounter);
            BaseLifeCycle.VerifyInstancePerTestCase(3);
        }
Esempio n. 7
0
        public void AssemblyLevelInstancePerTestCaseShouldCreateInstanceForEachTestCase()
        {
            var asm = TestAssemblyHelper.GenerateInMemoryAssembly(
                AssemblyLevelFixtureLifeCycleTest.Code, 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.VerifyInstancePerTestCase(2);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public void InstancePerTestCaseFullLifeCycleTest()
        {
            BaseLifeCycle.Reset();
            var fixture = TestBuilder.MakeFixture(typeof(FullLifecycleTestCase));
            var attr    = new FixtureLifeCycleAttribute(LifeCycle.InstancePerTestCase);

            attr.ApplyToTest(fixture);

            ITestResult result = TestBuilder.RunTest(fixture);

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Passed), result.Message);

            BaseLifeCycle.VerifyInstancePerTestCase(3);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
 public void SetUp()
 {
     BaseLifeCycle.Reset();
 }