本文整理汇总了C#中ChangeTrackingCollection类的典型用法代码示例。如果您正苦于以下问题:C#ChangeTrackingCollection类的具体用法?C#ChangeTrackingCollection怎么用?C#ChangeTrackingCollection使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:ShoudNotTrackRemovedItemAsModified
publicvoidShoudNotTrackRemovedItemAsModified()
{
varwordToAdd=newWordWrapper(newWord());
varcollection=newChangeTrackingCollection
(words);
Assert.AreEqual(2,collection.Count);
Assert.IsFalse(collection.IsChanged);
collection.Add(wordToAdd);
Assert.AreEqual(3,collection.Count);
Assert.AreEqual(1,collection.AddedItems.Count);
Assert.AreEqual(0,collection.RemovedItems.Count);
Assert.AreEqual(0,collection.ModifiedItems.Count);
Assert.AreEqual(wordToAdd,collection.AddedItems.First());
Assert.IsTrue(collection.IsChanged);
collection.Remove(wordToAdd);
Assert.AreEqual(2,collection.Count);
Assert.AreEqual(0,collection.AddedItems.Count);
Assert.AreEqual(0,collection.RemovedItems.Count);
Assert.AreEqual(0,collection.ModifiedItems.Count);
Assert.IsFalse(collection.IsChanged);
}
原文链接:http://www.jxszl.com/biancheng/C/556719.html