public void Repository_Should_Add_Connection() { ConnectionJsonRepository repo = new ConnectionJsonRepository(); Console.WriteLine($"Adding Database .: {_testConnection.Database}"); var addedConn = repo.Save(_testConnection); Assert.Equal(_testConnection.Database, addedConn.Database); }
public void DatabaseRepository_FindByName_Should_Return_Null_When_DatabaseConnection_Is_Invalid() { //Arrange DatabaseRepository databaseRepo = new DatabaseRepository(_log); ConnectionJsonRepository connRepo = new ConnectionJsonRepository(); //Act var conn = connRepo.FindByName("XXXXX"); TableSchema table = databaseRepo.FindByName(conn, "TESTE_01"); //Assert Assert.True(table == null); }
public void Repository_Should_Remove_Connection() { ConnectionJsonRepository repo = new ConnectionJsonRepository(); _testConnection.Name = "PepeJaTireiAVela"; repo.Save(_testConnection); var connection = repo.FindByName("PepeJaTireiAVela"); Console.WriteLine($"Removing Database.: {connection.Database}"); repo.Remove(connection.Id); var connectionFound = repo.FindByName("PepeJaTireiAVela"); Assert.Equal(null, connectionFound); }
public void DatabaseRepository_GetAll_Should_Return_All_Tables() { DatabaseRepository databaseRepo = new DatabaseRepository(_log); ConnectionJsonRepository connRepo = new ConnectionJsonRepository(); var conn = connRepo.FindByName("TESTE_01"); var list = databaseRepo.GetAll(conn); foreach (var table in list) { Console.WriteLine($"Table Id.: {table.Id} Name.: {table.Name}"); } Assert.True(list.Count() > 0); }
public void Repository_Should_Update_Connection() { ConnectionJsonRepository repo = new ConnectionJsonRepository(); var connection = _testConnection; Console.WriteLine($"Updating Database .: {connection?.Database}"); Console.WriteLine($"Current Database .: {connection?.Database}, Server.: {connection?.Server}"); connection.Database = "MySql"; connection.Server = "Localhost"; var addedConn = repo.Save(connection); var connectionSaved = repo.FindByName("Pepe_teste"); Console.WriteLine($"Database Updated .: {connectionSaved.Database}, Server.: {connectionSaved.Server}"); Assert.Equal(connection.Database, addedConn.Database); }
public void DatabaseRepository_FindByName_Should_Return_Table_With_Relashionships() { DatabaseRepository databaseRepo = new DatabaseRepository(_log); ConnectionJsonRepository connRepo = new ConnectionJsonRepository(); var conn = connRepo.FindByName("TESTE_01"); TableSchema table = databaseRepo.FindByName(conn, "NOTA_FISCAL_ITEM"); Console.WriteLine($"Table Id.: {table?.Id} Name.: {table?.Name}"); foreach (var tableRef in table?.ForeignKeys) { _log.LogDebug($"Fk Name.: {tableRef.Name}"); } Assert.True(table != null); }