public void Test_that_executes_action_twice_when_is_used_wrong_connection_string()
        {
            // Arrange
            var mi = MockInfo <TestEntity, bool> .CreateForResult(x => x.RecordExists(It.IsAny <TestEntity>()));

            var m = mi.CreateMockForSequence(MockConfig.WrongConnectionString);

            var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object));

            // Act - Assert
            Assert.ThrowsException <StorageException>(() => tableStorage.RecordExists(It.IsAny <TestEntity>()));
            m.Verify(foo => foo.RecordExists(It.IsAny <TestEntity>()), Times.Exactly(2));
        }
        public async Task Test_that_async_with_result_executes_action_twice_when_is_used_wrong_connection_string()
        {
            // Arrange
            var mi = MockInfo <TestEntity, Task <TestEntity> > .CreateForTaskResult(x => x.GetTopRecordAsync(It.IsAny <string>()));

            var m = mi.CreateMockForSequence(MockConfig.WrongConnectionString);

            var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object));

            // Act - Assert
            await Assert.ThrowsExceptionAsync <StorageException>(() => tableStorage.GetTopRecordAsync(It.IsAny <string>()));

            m.Verify(foo => foo.GetTopRecordAsync(It.IsAny <string>()), Times.Exactly(2));
        }
        public async Task Test_that_async_with_result_executes_action_once_when_is_used_good_connection_string()
        {
            // Arrange
            var mi = MockInfo <TestEntity, Task <TestEntity> > .CreateForTaskResult(x => x.GetTopRecordAsync(It.IsAny <string>()));

            var m = mi.CreateMockForSequence(MockConfig.GoodConnectionString);

            var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object));

            // Act
            await tableStorage.GetTopRecordAsync(It.IsAny <string>());

            // Assert
            m.Verify(foo => foo.GetTopRecordAsync(It.IsAny <string>()), Times.Once);
        }
        public void Test_that_executes_action_once_when_is_used_good_connection_string()
        {
            // Arrange
            var mi = MockInfo <TestEntity, bool> .CreateForResult(x => x.RecordExists(It.IsAny <TestEntity>()));

            var m = mi.CreateMockForSequence(MockConfig.GoodConnectionString);

            var tableStorage = new ReloadingConnectionStringOnFailureAzureTableStorageDecorator <TestEntity>(_ => Task.FromResult(m.Object));

            // Act
            tableStorage.RecordExists(It.IsAny <TestEntity>());

            // Assert
            m.Verify(foo => foo.RecordExists(It.IsAny <TestEntity>()), Times.Once);
        }
        public async Task Test_that_async_executes_action_twice_when_is_reloaded_good_connection_string()
        {
            // Arrange
            var mi = MockInfo <TestEntity, Task> .CreateForTask(x => x.DeleteAsync(It.IsAny <TestEntity>()));

            var m = mi.CreateMockForSequence(MockConfig.WrongConnectionString, 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.Exactly(2));
        }