public async Task MarkInitializedAsync_ShouldThrow_IfMarkerThrows() { var client = Mock.Of <IChangeFeedDocumentClient>(); Mock.Get(client) .Setup(c => c.CreateDocumentAsync(It.IsAny <string>(), It.IsAny <object>(), null, false, default(CancellationToken))) .ThrowsAsync(DocumentExceptionHelpers.CreateRequestRateTooLargeException()); var leaseStore = new DocumentServiceLeaseStore(client, collectionInfo, containerNamePrefix, leaseCollectionLink, Mock.Of <IRequestOptionsFactory>()); Exception exception = await Record.ExceptionAsync(async() => await leaseStore.MarkInitializedAsync()); Assert.IsAssignableFrom <DocumentClientException>(exception); }
public async Task MarkInitializedAsync_ShouldSucceed_IfMarkerConflicts() { var client = Mock.Of <IChangeFeedDocumentClient>(); Mock.Get(client) .Setup(c => c.CreateDocumentAsync(It.IsAny <string>(), It.IsAny <object>(), null, false, default(CancellationToken))) .ThrowsAsync(DocumentExceptionHelpers.CreateConflictException()); var leaseStore = new DocumentServiceLeaseStore(client, collectionInfo, containerNamePrefix, leaseCollectionLink, Mock.Of <IRequestOptionsFactory>()); await leaseStore.MarkInitializedAsync(); Mock.Get(client) .Verify(c => c.CreateDocumentAsync(leaseCollectionLink, It.Is <Document>(d => d.Id == storeMarker), null, false, default(CancellationToken)), Times.Once); }