Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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.");
        }
Beispiel #4
0
        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.");
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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.");
        }
Beispiel #7
0
        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.");
        }