public void Should_Not_Track_Added_Item_As_Modified() { var listItemToAdd = new PocoListItemAdapter(new PocoListItem()); var c = new ChangeTrackingCollection <PocoListItemAdapter>(_listItems); c.Add(listItemToAdd); listItemToAdd.Description = "modified entry"; Assert.IsTrue(listItemToAdd.IsChanged); Assert.AreEqual(3, c.Count); Assert.AreEqual(1, c.AddedItems.Count); Assert.AreEqual(0, c.RemovedItems.Count); Assert.AreEqual(0, c.ModifiedItems.Count); Assert.IsTrue(c.IsChanged); }
public void Should_Reject_Changes() { var listItemToAdd = new PocoListItemAdapter(new PocoListItem { Id = 3, Title = "TestItem03", Description = "Description03" }); var listItemToModify = _listItems.First(); var listItemToRemove = _listItems.Skip(1).First(); var c = new ChangeTrackingCollection <PocoListItemAdapter>(_listItems); c.Add(listItemToAdd); c.Remove(listItemToRemove); listItemToModify.Description = "modified item"; Assert.AreEqual("Description01", listItemToModify.DescriptionOriginal); Assert.AreEqual(2, c.Count); Assert.AreEqual(1, c.AddedItems.Count); Assert.AreEqual(1, c.ModifiedItems.Count); Assert.AreEqual(1, c.RemovedItems.Count); c.RejectChanges(); Assert.AreEqual(2, c.Count); Assert.IsTrue(c.Contains(listItemToModify)); Assert.IsTrue(c.Contains(listItemToRemove)); Assert.AreEqual(0, c.AddedItems.Count); Assert.AreEqual(0, c.ModifiedItems.Count); Assert.AreEqual(0, c.RemovedItems.Count); Assert.IsFalse(listItemToModify.IsChanged); Assert.AreEqual("Description01", listItemToModify.Description); Assert.AreEqual("Description01", listItemToModify.DescriptionOriginal); Assert.IsFalse(c.IsChanged); }
public void Should_Track_Added_Items() { var listItemToAdd = new PocoListItemAdapter(new PocoListItem()); var c = new ChangeTrackingCollection <PocoListItemAdapter>(_listItems); Assert.AreEqual(2, c.Count); Assert.IsFalse(c.IsChanged); c.Add(listItemToAdd); Assert.AreEqual(3, c.Count); Assert.AreEqual(1, c.AddedItems.Count); Assert.AreEqual(0, c.RemovedItems.Count); Assert.AreEqual(0, c.ModifiedItems.Count); Assert.AreEqual(listItemToAdd, c.AddedItems.First()); Assert.IsTrue(c.IsChanged); c.Remove(listItemToAdd); Assert.AreEqual(2, c.Count); Assert.AreEqual(0, c.AddedItems.Count); Assert.AreEqual(0, c.RemovedItems.Count); Assert.AreEqual(0, c.ModifiedItems.Count); Assert.IsFalse(c.IsChanged); }
protected override void InitializeComplexProperties(PocoTestClass model) { ComplexProp = new PocoListItemAdapter(model.ComplexProp); RegisterComplex(ComplexProp); }