public void Add_modify_means_changes_on_each_op() { 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()); product.UnitPrice++; Assert.AreEqual(true, context.HasChanges()); }
public void Add_delete_means_no_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()); context.Set <ProductPoco>().Delete(product); Assert.AreEqual(false, context.HasChanges()); }
public void Attach_modify_means_changes_at_the_end() { var context = new OEContext(); var product = new ProductPoco() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <ProductPoco>().Attach(product); Assert.AreEqual(false, context.HasChanges()); product.UnitPrice++; Assert.AreEqual(true, context.HasChanges()); }
public void Attach_detach_means_no_changes() { var context = new OEContext(); var product = new Product() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <Product>().Attach(product); Assert.AreEqual(false, context.HasChanges()); context.Set <Product>().Detach(product); Assert.AreEqual(false, context.HasChanges()); }
public void Ignore_Attach_modify_no_changes() { var context = new OEContext(); var product = new Product() { Id = 1, Name = "Test product", UnitPrice = 100, Category = "Test category" }; context.Set <Product>().Attach(product); Assert.AreEqual(false, context.HasChanges()); product.Category = "Modified category"; Assert.AreEqual(false, context.HasChanges()); }
public void CancelChanges_cancels_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.CancelChanges(); Assert.AreEqual(false, context.HasChanges()); Assert.AreEqual(0, context.GetChanges().Count()); }
public void ApplyChanges_applies_added_changes() { var context = new OEContext(); var product = new Product() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <Product>().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 <Product>().GetAll().Count()); }
public void CancelChanges_cancels_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.CancelChanges(); Assert.AreEqual(false, context.HasChanges()); Assert.AreEqual(0, context.GetChanges().Count()); }
public void Add_means_changes() { var context = new OEContext(); var product = new Product() { Id = 1, Name = "Test product", UnitPrice = 100 }; context.Set <Product>().Add(product); Assert.AreEqual(true, context.HasChanges()); }