public override IReturns <IDocumentsOperations, Task <AzureOperationResponse <long> > > Setup() { return(DocumentOperations .Setup(x => x.CountWithHttpMessagesAsync( It.IsAny <SearchRequestOptions>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))); }
public override IReturns <IDocumentsOperations, Task <AzureOperationResponse <DocumentSearchResult <object> > > > Setup() { return(DocumentOperations .Setup(x => x.SearchWithHttpMessagesAsync <object>( It.IsAny <string>(), It.IsAny <SearchParameters>(), It.IsAny <SearchRequestOptions>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))); }
public async Task DoesNotWrapIndexBatchException() { DocumentOperations .Setup(x => x.IndexWithHttpMessagesAsync( It.IsAny <IndexBatch <object> >(), It.IsAny <SearchRequestOptions>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .ThrowsAsync(new IndexBatchException(new DocumentIndexResult(new List <IndexingResult>()))); await Assert.ThrowsAsync <IndexBatchException>( () => Target.IndexAsync(new IndexBatch <object>(Enumerable.Empty <IndexAction <object> >()))); }
public async Task DoesNotRetryOnNullReferenceException() { DocumentOperations .Setup(x => x.IndexWithHttpMessagesAsync( It.IsAny <IndexBatch <object> >(), It.IsAny <SearchRequestOptions>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .ThrowsAsync(new NullReferenceException()); var ex = await Assert.ThrowsAsync <NullReferenceException>( () => Target.IndexAsync(new IndexBatch <object>(Enumerable.Empty <IndexAction <object> >()))); Assert.Equal(1, DocumentOperations.Invocations.Count); }
public async Task DoesNotHandleNotFoundException() { DocumentOperations .Setup(x => x.IndexWithHttpMessagesAsync( It.IsAny <IndexBatch <object> >(), It.IsAny <SearchRequestOptions>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .ThrowsAsync(new CloudException { Response = new HttpResponseMessageWrapper(new HttpResponseMessage(HttpStatusCode.NotFound), string.Empty), }); await Assert.ThrowsAsync <CloudException>( () => Target.IndexAsync(new IndexBatch <object>(Enumerable.Empty <IndexAction <object> >()))); }