Example #1
0
        public async Task OnDocumentError_is_run_when_a_document_has_a_processing_error()
        {
            var onDocumentErrorActionRun = false;
            var document  = new TestDocument(Generate.Bytes());
            var exception = new Exception("An exception");
            var source    = Observable.Repeat(document, 1);

            await _sut.WithDocumentsFrom(source)
            .Then(d => throw exception)
            .OnDocumentError(err =>
            {
                Assert.Same(document, err.Document);
                Assert.Same(exception, err.Exception);
                onDocumentErrorActionRun = true;
            })
            .RunAsync();

            Assert.True(onDocumentErrorActionRun);
        }
Example #2
0
        public async Task OnDocumentError_is_run_when_a_document_has_an_error_during_creation()
        {
            var onDocumentErrorActionRun = false;
            var document  = new TestDocument(Generate.Bytes());
            var exception = new Exception("Could not create document");
            var source    = Observable.Repeat(document, 1);

            _documentFactory
            .CreateDocumentAsync(Arg.Any <Document>())
            .Throws(exception);

            await _sut.WithDocumentsFrom(source)
            .OnDocumentError(err =>
            {
                Assert.Same(document, err.Document);
                Assert.NotNull(err.Exception);
                Assert.Null(err.Exception.InnerException);
                Assert.Equal(err.Exception.Message, exception.Message);
                onDocumentErrorActionRun = true;
            })
            .RunAsync();

            Assert.True(onDocumentErrorActionRun);
        }