public void ExpectCondition_ContainsErrorDetails_WhenTimedOut()
        {
            this.AssertErrorDetailsAfterOneSecond(
                Never.ExpectWithinSeconds(1).BoxResult(),
                @"\[!\] Never EXPECTED WITHIN.*
\s+Failed with.*
\s+Test operation stack");
        }
Exemple #2
0
        public void Dispose_CancelsInstructions()
        {
            var task = Never.ExpectWithinSeconds(1).ToTask(this.Executor);

            this.Executor.Dispose();
            var exception = GetFailureException(task);

            Assert.IsInstanceOf <TaskCanceledException>(exception.InnerException);
        }
        public void ExpectWithinSeconds_CancelsSuccessfully()
        {
            var cts  = new CancellationTokenSource();
            var task = Never
                       .ExpectWithinSeconds(1)
                       .ToTask(this.Executor, cts.Token);

            cts.Cancel();
            var error = GetFailureException(task);

            Assert.IsInstanceOf <TaskCanceledException>(error.InnerException);
        }
        public void ExpectResponder_ContainsErrorDetails_WhenInstructionTimedOut()
        {
            var responder = ImmediateTrue.ThenRespondWith("Response", Never.ExpectWithinSeconds(0.5));

            this.AssertErrorDetailsAfterOneSecond(
                responder.BoxResult().ExpectWithinSeconds(1),
                @"timed out.*
\[!\] Response EXPECTED WITHIN.*
\s+\[!\] Never EXPECTED WITHIN.*
\s+Failed with.*
\s+Test operation stack");
        }
        public void ExpectCondition_TerminatesWithError_AfterTimeout()
        {
            var task = Never
                       .ExpectWithinSeconds(1)
                       .ToTask(this.Executor);

            Assert.IsFalse(task.IsFaulted);
            this.Scheduler.AdvanceFrame(OneSecond);
            var error = GetFailureException(task);

            Assert.IsInstanceOf <TimeoutException>(error.InnerException);
        }
Exemple #6
0
        public void WaitMessage_ContainsCorrectDetails()
        {
            var state = Never.ExpectWithinSeconds(1).CreateState();

            this.AdvanceDefaultFrame();             // Should not count in time

            state.ToTask(this.Executor);            // Start execution

            StateAssert.StringContainsInOrder(state.ToString())
            .Waiting("Never")
            .Details(@"Started 0\.00 s ≈ 0 frames ago");

            this.AdvanceDefaultFrame();
            StateAssert.StringContainsInOrder(state.ToString())
            .Waiting("Never")
            .Details($@"Started {OneFrame.TotalSeconds:0.00} s ≈ 1 frames ago");
        }
Exemple #7
0
        public void CanceledMessage_ContainsCorrectDetails()
        {
            using (var cts = new CancellationTokenSource())
            {
                var state = Never.ExpectWithinSeconds(1).CreateState();

                this.AdvanceDefaultFrame();                 // Should not count in time

                // Start execution, canceled after one frame
                state.ToTask(this.Executor, cts.Token);
                this.AdvanceDefaultFrame();
                cts.Cancel();

                StateAssert.StringContainsInOrder(state.ToString())
                .Canceled("Never")
                .Details($@"Canceled after {OneFrame.TotalSeconds:0.00} s ≈ 1 frames");
            }
        }