public void RespondToAnyOf_WorksCorrectlyWithReferenceTypes() { var expectedObject = new object(); var instruction = RespondToAnyOf( ImmediateTrue.ThenRespondWith("Return object", Return(expectedObject)), this.responder1.Responder.BoxResult()) .Until(Never) .ExpectWithinSeconds(1); Assert.DoesNotThrow(() => instruction.ToTask(this.Executor)); }
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 BasicResponder_Fails_WhenContinuationThrows() { var task = ImmediateTrue .ThenRespondWith <bool, object>( "Throw exception in selector", _ => throw new Exception("Test exception")) .ExpectWithinSeconds(1) .ToTask(this.Executor); var exception = GetFailureException(task); StateAssert.StringContainsInOrder(exception.Message) .Failed("Throw exception in selector") .Completed("True") .Details("THEN RESPOND WITH ...") .Details("Test exception"); }
public void ExpectResponder_DoesNotTerminateWithTimeout_IfWaitFulfilled() { // The instruction takes longer than the timeout // => The timeout applies only to the wait! var task = ImmediateTrue .ThenRespondWith("Wait for two seconds", WaitForSeconds(2)) .ExpectWithinSeconds(1) .ToTask(this.Executor); this.Scheduler.AdvanceFrame(OneSecond); Assert.IsFalse(task.IsFaulted); Assert.IsFalse(task.IsCompleted); this.Scheduler.AdvanceFrame(OneSecond); Assert.IsFalse(task.IsFaulted); Assert.IsTrue(task.IsCompleted); }