public void ExternalResult_IsReturned_WhenReturnedEarly() { var task = NeverZero.ToTask(this.Executor); Assert.IsFalse(task.IsCompleted); this.completionSource.SetResult(42); Assert.AreEqual(42, task.AssertSynchronousResult()); }
private void AssertErrorDetailsAfterOneSecond( ITestInstruction <object> instruction, [RegexPattern] string regex) { var task = instruction.ToTask(this.Executor); this.Scheduler.AdvanceFrame(OneSecond); var exception = GetFailureException(task); Assert.That(exception.Message, Does.Match($"(?s:{regex})")); var multipleFailuresDescription = $"Should contain only singe failure details, but was:\n{exception.Message}"; Assert.AreEqual( 1, Regex.Matches(exception.Message, "Failed with").Count, multipleFailuresDescription); Assert.AreEqual( 1, Regex.Matches(exception.Message, "Test operation stack").Count, multipleFailuresDescription); }
private void AssertEqual <T>(ITestInstruction <T> left, ITestInstruction <T> right) => Assert.AreEqual( left.ToTask(this.Executor).AssertSynchronousResult(), right.ToTask(this.Executor).AssertSynchronousResult());