public void WaitForCoroutine_ContainsCorrectDescription() { var instruction = Responsibly .WaitForCoroutine("Manual", this.ThrowImmediately) .ExpectWithinSeconds(1) .ToYieldInstruction(this.Executor); Assert.IsTrue(instruction.CompletedWithError); StringAssert.Contains("Manual (Coroutine)", instruction.Error.Message); }
public IEnumerator WaitForCoroutine_CompletesWithError_WhenCoroutineThrows() { var instruction = Responsibly .WaitForCoroutine("Throw", this.ThrowAfterOneFrame) .ExpectWithinSeconds(1) .ToYieldInstruction(this.Executor, throwOnError: false); yield return(instruction); Assert.IsTrue(instruction.CompletedWithError); Assert.AreSame(this.testException, instruction.Error.InnerException); }
public IEnumerator WaitForCoroutine_CompletesWithCoroutine() { var startFrame = Time.frameCount; yield return(Responsibly .WaitForCoroutine("Coroutine", this.CompleteAfterOneFrame) .ExpectWithinSeconds(1) .ToYieldInstruction(this.Executor)); Assert.AreEqual( 1, Time.frameCount - startFrame, "Coroutine should complete after one frame"); Assert.IsTrue(this.coroutineCompleted); }
public IEnumerator WaitForCoroutine_CancelsCoroutine_WhenOperationCanceled() { using (var cancellationSource = new CancellationTokenSource()) { var instruction = Responsibly .WaitForCoroutine("Forever", this.Forever) .ExpectWithinSeconds(1) .ToYieldInstruction(this.Executor, throwOnError: false, cancellationSource.Token); Assert.IsTrue(this.coroutineRan); yield return(null); this.coroutineRan = false; cancellationSource.Cancel(); yield return(null); yield return(null); Assert.IsFalse(this.coroutineRan); Assert.IsTrue(instruction.WasCanceled); } }