Exemple #1
0
        public void TestThatTimesOutIsRanToCompletionWhenDebuggerIsAttachedBeforeTimeOut()
        {
            // give
            var testThatAttachesDebuggerAndTimesOut =
                TestBuilder.MakeTestCase(typeof(SampleTests), nameof(SampleTests.TestThatAttachesDebuggerAndTimesOut));

            _debugger = new StubDebugger {
                IsAttached = false
            };

            // when
            var result = TestBuilder.RunTest(testThatAttachesDebuggerAndTimesOut, new SampleTests(), _debugger);

            // then
            Assert.That(_testRanToCompletion, () => "Test did not run to completion");
        }
Exemple #2
0
        public void TimeoutCausesOtherwisePassingTestToFailWithoutDebuggerAttached()
        {
            // given
            var testThatTimesOutButOtherwisePasses =
                TestBuilder.MakeTestCase(typeof(SampleTests), nameof(SampleTests.TestThatTimesOut));

            var detachedDebugger = new StubDebugger {
                IsAttached = false
            };

            // when
            var result = TestBuilder.RunTest(testThatTimesOutButOtherwisePasses, new SampleTests(), detachedDebugger);

            // then
            Assert.That(_testRanToCompletion == false, () => "Test ran to completion");

            Assert.That(result.ResultState.Status, Is.EqualTo(TestStatus.Failed));
            Assert.That(result.ResultState.Site, Is.EqualTo(FailureSite.Test));
            Assert.That(result.ResultState.Label, Is.EqualTo($"Test exceeded Timeout value {SampleTests.Timeout}ms."));
        }
Exemple #3
0
        public void TestThatTimesOutIsRanToCompletionAndItsResultIsPropagatedWhenDebuggerIsAttached(TestAction test)
        {
            // given
            _testAction = test.Action;

            var testThatTimesOut =
                TestBuilder.MakeTestCase(typeof(SampleTests), nameof(SampleTests.TestThatTimesOutAndInvokesAction));

            var attachedDebugger = new StubDebugger {
                IsAttached = true
            };

            // when
            var result = TestBuilder.RunTest(testThatTimesOut, new SampleTests(), attachedDebugger);

            // then
            Assert.That(_testRanToCompletion, () => "Test did not run to completion");

            test.Assertion.Invoke(result);
        }
Exemple #4
0
        public void TestThatCompletesWithinTimeoutPeriodHasItsOriginalResultPropagated(
            [ValueSource(nameof(PossibleTestOutcomes))] TestAction test,
            [Values] bool isDebuggerAttached)
        {
            // given
            _testAction = test.Action;

            var testThatCompletesWithoutTimeout =
                TestBuilder.MakeTestCase(typeof(SampleTests), nameof(SampleTests.TestThatInvokesActionImmediately));

            var debugger = new StubDebugger {
                IsAttached = isDebuggerAttached
            };

            // when
            var result = TestBuilder.RunTest(testThatCompletesWithoutTimeout, new SampleTests(), debugger);

            // then
            test.Assertion.Invoke(result);
        }