public void ApplyChanges_applies_added_changes() { var context = new OEContext(); var product = new ProductPoco() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <ProductPoco>().Add(product); Assert.AreEqual(true, context.HasChanges()); Assert.AreEqual(1, context.GetChanges().Count()); context.ApplyChanges(); Assert.AreEqual(false, context.HasChanges()); Assert.AreEqual(0, context.GetChanges().Count()); Assert.AreEqual(1, context.Set <ProductPoco>().GetAll().Count()); }
public void ApplyChanges_applies_attached_modified_changes() { var context = new OEContext(); var product = new Product() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <Product>().Attach(product); product.UnitPrice++; Assert.AreEqual(true, context.HasChanges()); Assert.AreEqual(1, context.GetChanges().Count()); context.ApplyChanges(); Assert.AreEqual(false, context.HasChanges()); Assert.AreEqual(0, context.GetChanges().Count()); Assert.AreEqual(1, context.Set <Product>().GetAll().Count()); }