IEnumerator TestWhenAllFaultedCoroutine(Fiber [] fibers) { // One fiber will cancel var waitAllFiber = Fiber.WhenAll (fibers); yield return waitAllFiber; // None should be running Assert.IsFalse (fibers.Any (f => f.Status == FiberStatus.Running), "No fibers should have been running"); // All should be complete Assert.IsTrue (fibers.All (f => f.IsCompleted), "All should be complete"); // 2 should be faulted Assert.AreEqual (2, fibers.Count (f => f.IsFaulted), "2 should be faulted"); // None should be canceled Assert.IsFalse (fibers.Any (f => f.IsCanceled), "None should be canceled"); // Result should not be present Assert.IsNull (waitAllFiber.ResultAsObject, "Result should not be present"); // Fiber should be faulted Assert.IsTrue (waitAllFiber.IsFaulted, "Fiber should have been faulted"); // Fiber should have exception Assert.IsNotNull (waitAllFiber.Exception, "Fiber should have exception"); // Exception should have 2 inner exceptions Assert.AreEqual (2, (waitAllFiber.Exception as AggregateException).InnerExceptions.Count, "Fiber should have 2 inner exceptions"); }
IEnumerator TestWhenAllChildCancellationCoroutine(Fiber [] fibers) { // One fiber will cancel var waitAllFiber = Fiber.WhenAll (fibers); yield return waitAllFiber; // None should be running Assert.IsFalse (fibers.Any (f => f.Status == FiberStatus.Running), "No fibers should have been running"); // All should be complete Assert.IsTrue (fibers.All (f => f.IsCompleted), "All should be complete"); // None should be faulted Assert.IsFalse (fibers.Any (f => f.IsFaulted), "None should be faulted"); // One should be canceled Assert.IsTrue (fibers.Count (f => f.IsCanceled) == 1, "One should be canceled"); // Result should not be present Assert.IsNull (waitAllFiber.ResultAsObject, "Result should not be present"); // Fiber should not be faulted Assert.IsFalse (waitAllFiber.IsFaulted, "Fiber should not be faulted"); // Fiber should be canceled Assert.IsTrue (waitAllFiber.IsCanceled, "Fiber should have been canceled"); }