示例#1
0
        public async Task GetValueAsync_Throws_WhenErrorResponse()
        {
            // Arrange
            IValueBinder binder = CreateBinder <Item>(out Mock <ICosmosDBService> mockService);

            mockService
            .Setup(m => m.ReadDocumentAsync(_expectedUri, null))
            .ThrowsAsync(CosmosDBTestUtility.CreateDocumentClientException(HttpStatusCode.ServiceUnavailable));

            // Act
            // TODO: Fix this up so it exposes the real exception
            var ex = await Assert.ThrowsAsync <DocumentClientException>(() => binder.GetValueAsync());

            // Assert
            Assert.Equal(HttpStatusCode.ServiceUnavailable, ex.StatusCode);
        }
示例#2
0
        public async Task GetValueAsync_DoesNotThrow_WhenResponseIsNotFound()
        {
            // Arrange
            IValueBinder binder = CreateBinder <Item>(out Mock <ICosmosDBService> mockService);

            mockService
            .Setup(m => m.ReadDocumentAsync(_expectedUri, null))
            .ThrowsAsync(CosmosDBTestUtility.CreateDocumentClientException(HttpStatusCode.NotFound));

            // Act
            var value = await binder.GetValueAsync();

            // Assert
            Assert.Null(value);
            mockService.VerifyAll();
        }