public void Calls_Connection_BeginTransaction() { // Arrange var(_, _, _, connection, db) = Db_Setup.Get(); // Act _ = db.UnitOfWork; // Assert connection.Received().BeginTransaction(); }
public void Calls_Client_Connect() { // Arrange var(_, _, client, _, db) = Db_Setup.Get(); // Act _ = db.UnitOfWork; // Assert client.Received().Connect(Arg.Any <string>()); }
public void Sets_Properties() { // Arrange // Act var(config, log, client, _, db) = Db_Setup.Get(); // Assert Assert.Same(client, db.Client); Assert.Same(config, db.Config); Assert.Same(log, db.LogTest); }
public async Task Without_Transaction_Connects_To_Client_And_Starts_New_Transaction() { // Arrange var(_, _, client, connection, db) = Db_Setup.Get(); var query = Rnd.Str; var parameters = Rnd.Guid.ToString(); const CommandType type = CommandType.Text; // Act await db.ExecuteAsync(query, parameters, type); // Assert client.Received().Connect(Arg.Any <string>()); connection.Received().BeginTransaction(); }
public async Task With_Return_Logs_Query_Info_To_Verbose() { // Arrange var(_, log, _, _, db) = Db_Setup.Get(); var query = Rnd.Str; var parameters = Rnd.Guid.ToString(); const CommandType type = CommandType.Text; var transaction = Substitute.For <IDbTransaction>(); // Act await db.ExecuteAsync <int>(query, parameters, type); await db.ExecuteAsync <int>(query, parameters, type, transaction); // Assert log.Received(2).Vrb("Query Type: {Type} | Return: {Return} | {Query} | Parameters: {Parameters}", type, typeof(int), query, parameters); }