public void UpdateSupplierFromProduct() { // Arrange Builder builder = new Builder( SqlDataMapperType, DataMapperParams, PropertyColumnMapperType, MultipleConnectionPolicyType); IDataMapper productMapper = builder.Build <Product>(); IConnectionPolicy explicitConnectionPolicy = productMapper.GetConnectionPolicy(); String fakeName = "teste"; String trueName = ""; String updatedName = ""; // Act Product p1 = (Product)productMapper.GetAll().First(); trueName = p1.SupplierID.CompanyName; p1.SupplierID.CompanyName = fakeName; productMapper.Update(p1); Product p2 = (Product)productMapper.GetAll().First(); updatedName = p2.SupplierID.CompanyName; p2.SupplierID.CompanyName = trueName; productMapper.Update(p2); // Assert Assert.AreEqual(fakeName, updatedName); }
public static void m3() { SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder(); sqlConnectionStringBuilder.DataSource = @"RoXaSDTD-PC\SQLEXPRESS"; sqlConnectionStringBuilder.InitialCatalog = "PlaylistManager"; sqlConnectionStringBuilder.UserID = "Rafael"; sqlConnectionStringBuilder.Password = "******"; sqlConnectionStringBuilder.IntegratedSecurity = true; string connectionString = sqlConnectionStringBuilder.ConnectionString; Builder builder = new Builder( typeof(SqlDataMapper <>), new Object[] { connectionString }, typeof(PropertyColumnMapper), typeof(MultipleConnectionPolicy)); IDataMapper <Playlist> playlistMapper = builder.Build <Playlist>(); IConnectionPolicy policy = playlistMapper.GetConnectionPolicy(); Playlist p = playlistMapper.GetAll().First(); p.name = "teste"; playlistMapper.Update(p); Playlist p2 = playlistMapper.GetAll().First(); p2.name = "JoanaPlaylist"; playlistMapper.Update(p2); }
public static void m1() { Builder builder = new Builder( typeof(SqlDataMapper <>), new Object[] { SqlMapperUnitTest.getMySqlConnectionString() }, typeof(PropertyColumnMapper), typeof(SingleConnectionPolicy)); IDataMapper <ProductSimple> productMapper = builder.Build <ProductSimple>(); IConnectionPolicy policy = productMapper.GetConnectionPolicy(); ProductSimple p = productMapper.GetAll().First(); p.ProductName = "Potatoes"; productMapper.Update(p); ProductSimple p2 = productMapper.GetAll().First(); p2.ProductName = "Chai"; productMapper.Update(p2); ProductSimple novoP = new ProductSimple(); novoP.ProductName = "batatas"; novoP.QuantityPerUnit = "setenta mil"; productMapper.Insert(novoP); }
public static void m2() { Builder builder = new Builder( typeof(SqlDataMapper <>), new Object[] { SqlMapperUnitTest.getMySqlConnectionString() }, typeof(PropertyColumnMapper), typeof(ExplicitConnectionPolicy)); IDataMapper <ProductSimple> productMapper = builder.Build <ProductSimple>(); IConnectionPolicy explicitConnectionPolicy = productMapper.GetConnectionPolicy(); // Act explicitConnectionPolicy.OpenConnection(); explicitConnectionPolicy.BeginTransaction(); ProductSimple p1 = productMapper.GetAll().First(); p1.ProductName = "Potatoes"; productMapper.Update(p1); ProductSimple p2 = productMapper.GetAll().First(); // Assert bool result = p1.ProductName == p2.ProductName; explicitConnectionPolicy.RollBack(); explicitConnectionPolicy.Dispose(); }
public void UpdateProductsWithSuccess() { // Arrange Builder builder = new Builder( SqlDataMapperType, DataMapperParams, PropertyColumnMapperType, ExplicitConnectionPolicyType); IDataMapper <ProductSimple> productMapper = builder.Build <ProductSimple>(); IConnectionPolicy explicitConnectionPolicy = productMapper.GetConnectionPolicy(); // Act explicitConnectionPolicy.OpenConnection(); explicitConnectionPolicy.BeginTransaction(); ProductSimple p1 = productMapper.GetAll().First(); p1.ProductName = "Potatoes"; productMapper.Update(p1); ProductSimple p2 = productMapper.GetAll().First(); // Assert Assert.AreEqual(p1.ProductName, p2.ProductName); explicitConnectionPolicy.RollBack(); explicitConnectionPolicy.Dispose(); }