public IEnumerator AssertTaskFaulted_ShouldWork_WithFirestoreException() { var tcs = new TaskCompletionSource <object>(); tcs.SetException(new FirestoreException(FirestoreError.Unavailable)); yield return(tcs.Task); Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Unavailable); }, Throws.Nothing); }
public IEnumerator AssertTaskFaulted_ShouldWork_WithMatchingMessage() { var tcs = new TaskCompletionSource <object>(); tcs.SetException(new FirestoreException(FirestoreError.Ok, "TheActualMessage")); yield return(tcs.Task); Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok, "The.*Message"); }, Throws.Nothing); }
public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithNonFirestoreException() { var tcs = new TaskCompletionSource <object>(); tcs.SetException(new InvalidOperationException()); yield return(tcs.Task); Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, Throws.Exception, "AssertTaskFaults() should have thrown an exception because the task faulted " + "with an incorrect exception type."); }
public IEnumerator AssertTaskFaulted_ShouldThrow_WhenTaskCompletes() { var tcs = new TaskCompletionSource <object>(); tcs.SetResult(null); yield return(tcs.Task); Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, Throws.Exception, "AssertTaskFaults() should have thrown an exception because the task faulted " + "with an incorrect error code."); }
public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithMissingMessages() { var tcs = new TaskCompletionSource <object>(); tcs.SetException(new FirestoreException(FirestoreError.Ok)); yield return(tcs.Task); Exception thrownException = Assert.Throws <AssertionException>( () => TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok, "SomeMessageRegex")); Assert.That(thrownException.Message, Contains.Substring("SomeMessageRegex"), "AssertTaskFaults() threw an exception (as expected); however, its message was " + "incorrect: " + thrownException.Message); }
public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithMoreThanOneInnerExceptions() { var tcs = new TaskCompletionSource <object>(); var exception1 = new InvalidOperationException(); var exception2 = new InvalidOperationException(); var exception3 = new AggregateException(new[] { exception1, exception2 }); tcs.SetException(exception3); yield return(tcs.Task); Assert.That(() => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Ok); }, Throws.Exception, "AssertTaskFaults() should have thrown an exception because the task faulted " + "with an AggregateException that could not be fully flattened."); }
public IEnumerator AssertTaskFaulted_ShouldThrow_IfFaultedWithAggregateException() { var tcs = new TaskCompletionSource <object>(); var firestoreException = new FirestoreException(FirestoreError.Unavailable); var aggregateException1 = new AggregateException(new[] { firestoreException }); var aggregateException2 = new AggregateException(new[] { aggregateException1 }); tcs.SetException(aggregateException2); yield return(tcs.Task); Assert.That( () => { TestAsserts.AssertTaskFaulted(tcs.Task, FirestoreError.Unavailable); }, Throws.Exception, "AssertTaskFaults() should have thrown an exception because the AggregateException" + "has multiple nested AggregateException instances."); }