public async Task SupportsTransactionVerificationWithoutSetup() { var connectionFactory = new Mock <IDbConnectionFactory>(); var connection = new MockDbConnection(); var repository = new SampleRepository(connectionFactory.Object); connectionFactory .Setup(f => f.OpenConnection()) .Returns(connection); await repository.DeleteCarAsync("Vauxhall"); connection.Verify(c => c.ExecuteAsync(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <IDbTransaction>(), null, null)); }
public async Task ExecuteAsync() { var connectionFactory = new Mock <IDbConnectionFactory>(); var connection = new MockDbConnection(); var repository = new SampleRepository(connectionFactory.Object); connectionFactory .Setup(f => f.OpenConnection()) .Returns(connection); await repository.DeleteCarAsync("ABC123"); connection.Verify(c => c.ExecuteAsync(@"delete from [Cars] where Registration = @registration", new { registration = "ABC123" }, It.IsAny <IDbTransaction>(), null, null)); }