public async Task MarkInitializedAsync_ShouldSucceed_IfMarkerCreated() { var client = Mock.Of <IChangeFeedDocumentClient>(); var leaseStore = new LeaseStore(client, collectionInfo, containerNamePrefix, leaseStoreCollectionLink); await leaseStore.MarkInitializedAsync(); Mock.Get(client) .Verify(c => c.CreateDocumentAsync(leaseStoreCollectionLink, It.Is <Document>(d => d.Id == storeMarker)), Times.Once); }
public async Task MarkInitializedAsync_ShouldThrow_IfMarkerThrows() { var client = Mock.Of <IChangeFeedDocumentClient>(); Mock.Get(client) .Setup(c => c.CreateDocumentAsync(It.IsAny <string>(), It.IsAny <object>())) .ThrowsAsync(DocumentExceptionHelpers.CreateRequestRateTooLargeException()); var leaseStore = new LeaseStore(client, collectionInfo, containerNamePrefix, leaseStoreCollectionLink); 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>())) .ThrowsAsync(DocumentExceptionHelpers.CreateConflictException()); var leaseStore = new LeaseStore(client, collectionInfo, containerNamePrefix, leaseStoreCollectionLink); await leaseStore.MarkInitializedAsync(); Mock.Get(client) .Verify(c => c.CreateDocumentAsync(leaseStoreCollectionLink, It.Is <Document>(d => d.Id == storeMarker)), Times.Once); }