public static GSMEF.Vente ConvertFromDTO(VenteDTO data) { GSMEF.Vente V = new GSMEF.Vente() { Id = data.Id, ArticleId = data.ArticleId, DateVente = data.DateVente, MontantVente = data.MontantVente }; return V; }
public void TestAddVente() { using (var ctx = new GSMDBEntities()) { var art = ctx.Articles.Where(a => a.Désignation.Equals("05 55 26 33 20")).SingleOrDefault(); Vente v = new Vente() { ArticleId = art.Id, DateVente = DateTime.Now.AddDays(-1), MontantVente = 10000 }; art.Ventes.Add(v); int count = ctx.SaveChanges(); Assert.IsTrue(count != 0 && v.Id != 0); } }