예제 #1
0
        public void ThrowsOnIncorrectState()
        {
            var run = new TestRun(new Mock <ITestResultLogger>().Object);

            Assert.Throws <InvalidOperationException>(() => run.EventOccured(MakeReadyEvent(1)));
            run.Start();

            Assert.AreEqual(TestRun.State.WaitingForReady, run.CurrentState);
            Assert.Throws <InvalidOperationException>(() => run.EventOccured(MakeTestPassedEvent("foo")));
            Assert.Throws <InvalidOperationException>(() => run.EventOccured(MakeTestAssertedEvent("foo")));

            run.EventOccured(MakeReadyEvent(1));
            Assert.Throws <InvalidOperationException>(() => run.EventOccured(MakeReadyEvent(1)));
        }
예제 #2
0
        public void StartupSequenceIsCorrect()
        {
            var run = new TestRun(new Mock <ITestResultLogger>().Object);

            Assert.AreEqual(TestRun.State.NotStarted, run.CurrentState);
            run.Start();
            Assert.AreEqual(TestRun.State.WaitingForReady, run.CurrentState);
            run.EventOccured(MakeReadyEvent(1));
            Assert.AreEqual(TestRun.State.Ready, run.CurrentState);
            run.EventOccured(MakeTestStartedEvent("foo"));
            Assert.AreEqual(TestRun.State.Running, run.CurrentState);
            run.EventOccured(MakeTestPassedEvent("foo"));
            Assert.AreEqual(TestRun.State.Finished, run.CurrentState);
        }
예제 #3
0
        public void CancelsTheRestWhenATestTimesOut()
        {
            var run = new TestRun(new Mock <ITestResultLogger>().Object, _veryShortTimeout, _arbitraryLongTimeout);

            run.Start();
            run.EventOccured(MakeReadyEvent(3));
            run.EventOccured(MakeTestStartedEvent("foo"));
            Thread.Sleep(2);
            var tests = run.WaitUntilFinished();

            Assert.IsTrue(tests[0].HasTimedOut);
            Assert.IsFalse(tests[1].HasTimedOut);
            Assert.IsFalse(tests[2].HasTimedOut);
            Assert.IsTrue(tests.TrueForAll(t => t.Failed));
        }
예제 #4
0
        public void RunsAllTestsInCorrectOrder()
        {
            var run = new TestRun(new Mock <ITestResultLogger>().Object);

            run.Start();
            run.EventOccured(MakeReadyEvent(2));
            run.EventOccured(MakeTestStartedEvent("foo"));
            run.EventOccured(MakeTestPassedEvent("foo"));
            run.EventOccured(MakeTestStartedEvent("bar"));
            run.EventOccured(MakeTestAssertedEvent("bar"));
            Assert.AreEqual(TestRun.State.Finished, run.CurrentState);

            var result = run.WaitUntilFinished();

            Assert.AreEqual(new string[] { "foo", "bar" }, result.Select(test => test.Name));
        }