public async Task Test_that_async_executes_action_twice_when_is_used_wrong_connection_string() { // Arrange var mi = MockInfo <TestEntity, Task> .CreateForTask(x => x.DeleteAsync(It.IsAny <TestEntity>())); var m = mi.CreateMockForSequence(MockConfig.WrongConnectionString); var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object)); // Act - Assert await Assert.ThrowsExceptionAsync <StorageException>(() => tableStorage.DeleteAsync(It.IsAny <TestEntity>())); m.Verify(foo => foo.DeleteAsync(It.IsAny <TestEntity>()), Times.Exactly(2)); }
public async Task Test_that_async_executes_action_once_when_is_used_good_connection_string() { // Arrange var mi = MockInfo <TestEntity, Task> .CreateForTask(x => x.DeleteAsync(It.IsAny <TestEntity>())); var m = mi.CreateMockForSequence(MockConfig.GoodConnectionString); var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object)); // Act await tableStorage.DeleteAsync(It.IsAny <TestEntity>()); // Assert m.Verify(foo => foo.DeleteAsync(It.IsAny <TestEntity>()), Times.Once); }