public async Task ExecuteShouldDisposeConnection() { var connection = NewOpenConnection(); var connectionHelper = new DefaultConnectionHelper(() => connection.Object); await connectionHelper.ExecuteAsync(dbConnection => Task.CompletedTask); connection.Verify(x => x.Dispose(), Times.Once); }
public async Task ExecuteWithResultShouldDisposeConnection() { var connection = NewOpenConnection(); var connectionHelper = new DefaultConnectionHelper(() => connection.Object); await connectionHelper.ExecuteAsync <int>(dbConnection => Task.FromResult(0)); connection.Verify(x => x.Dispose(), Times.Once); }
public async Task ExecuteWithReturnShouldThrowWhenActionIsNull() { var connectionHelper = new DefaultConnectionHelper(() => null); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => connectionHelper.ExecuteAsync <int>(null)); }