Пример #1
0
        public void MethodUnderTestProvidedToBeforeAfter()
        {
            MethodInfo         methodInfo = typeof(InstrumentedTestClass).GetMethod("PassedTest");
            StubTestCommand    stub       = new StubTestCommand();
            BeforeAfterCommand command    = new BeforeAfterCommand(stub, methodInfo);

            InstrumentedTestClass.Reset();

            command.Execute(new InstrumentedTestClass());

            Assert.Same(methodInfo, BeforeAfterSpyAttribute.beforeMethod);
            Assert.Same(methodInfo, BeforeAfterSpyAttribute.afterMethod);
        }
Пример #2
0
        public void AfterTestThrows()
        {
            MethodInfo         methodInfo = typeof(InstrumentedTestClass).GetMethod("PassedTest");
            StubTestCommand    stub       = new StubTestCommand();
            BeforeAfterCommand command    = new BeforeAfterCommand(stub, methodInfo);

            InstrumentedTestClass.Reset();
            BeforeAfterSpyAttribute.afterTestThrowCount = 1;

            Assert.Throws <AfterTestException>(() => command.Execute(new InstrumentedTestClass()));

            Assert.Equal(1, BeforeAfterSpyAttribute.beforeTestCount);
            Assert.Equal(1, stub.ExecuteCount);
            Assert.Equal(1, BeforeAfterSpyAttribute.afterTestCount);
        }
Пример #3
0
            public void TestMethodCounters()
            {
                TestClassCommand command = new TestClassCommand();

                command.TypeUnderTest = Reflector.Wrap(typeof(InstrumentedTestClass));
                InstrumentedTestClass.Reset();
                InstrumentedTestClass.passedTestCalled = 0;
                InstrumentedTestClass.failedTestCalled = 0;
                InstrumentedTestClass.skipTestCalled   = 0;
                InstrumentedTestClass.nonTestCalled    = 0;

                TestClassCommandRunner.Execute(command, null, null, null);

                Assert.Equal(1, InstrumentedTestClass.dataCtorCalled);
                Assert.Equal(2, InstrumentedTestClass.ctorCalled);                  // Two non-skipped tests, the skipped test does not create an instance
                Assert.Equal(1, InstrumentedTestClass.passedTestCalled);
                Assert.Equal(1, InstrumentedTestClass.failedTestCalled);
                Assert.Equal(0, InstrumentedTestClass.skipTestCalled);
                Assert.Equal(0, InstrumentedTestClass.nonTestCalled);
                Assert.Equal(2, InstrumentedTestClass.disposeCalled);
                Assert.Equal(1, InstrumentedTestClass.dataDisposeCalled);
                Assert.Equal("ctorData ctor setFixture dispose ctor setFixture dispose disposeData ", InstrumentedTestClass.callOrder);
            }