public void RemoveAndReplaceWithBoundedMerge() { char c = 'A'; var sourceList = new List <_UO>(); for (int i = 1; i <= 20; ++i) { sourceList.Add(new _UO(c++.ToString(), i)); } var collection = new MergeableCollection <string, _UO>(sourceList); var zItem = new _UO("Z", 0); collection.Add(zItem); sourceList.Insert(0, new _UO("Z", 0)); UTVerify2.CollectionsAreEqual(sourceList, collection); var item = collection.FindFKID("Z"); UTVerify2.AreReferenceEqual(item, zItem); collection.Remove(item); var zItem2 = new _UO("Z", 0); sourceList[0] = zItem2; collection.Merge(new _UO[] { zItem2, sourceList[1] }, true, sourceList.Count); UTVerify2.CollectionsAreEqual(sourceList, collection); }
public void SortedCollectionInsertMiddleTest() { var sourceList = new List <_UO> { new _UO("A", 1), new _UO("B", 2), new _UO("X", 24), new _UO("Y", 25), new _UO("Z", 26), }; var updateList = new List <_UO> { new _UO("D", 4), new _UO("C", 3), new _UO("E", 5), }; var collection = new MergeableCollection <string, _UO>(sourceList); collection.Merge(updateList, true); updateList.Sort(); sourceList.InsertRange(2, updateList); UTVerify2.CollectionsAreEqual(sourceList, collection); }
public void SortedCollectionPropertyUpdatesTest() { var sourceList = new List <_UO> { new _UO("A", 1), new _UO("B", 3), new _UO("C", 5), new _UO("D", 7), new _UO("E", 9), }; sourceList.Reverse(); var collection = new MergeableCollection <string, _UO>(sourceList); sourceList.Reverse(); UTVerify2.CollectionsAreEqual(sourceList, collection); sourceList[0].SortValue = 2; UTVerify2.CollectionsAreEqual(sourceList, collection); var item = sourceList[1]; item.SortValue = 10; sourceList.RemoveAt(1); sourceList.Add(item); UTVerify2.CollectionsAreEqual(sourceList, collection); }
public SettingsBase() { Parameters = new MergeableCollection<Parameter>(); DataSources = new MergeableCollection<Source>(); DataSources.CollectionChanged += CollectionChanged; Parameters.CollectionChanged += CollectionChanged; }
public void ReplaceSingleItemWithMergeInUnboundedCollection() { char c = 'A'; var sourceList = new List <_UO>(); for (int i = 1; i <= 20; ++i) { sourceList.Add(new _UO(c++.ToString(), i)); } var collection = new MergeableCollection <string, _UO>(sourceList); collection.Add(new _UO("Z", 0)); sourceList.Insert(0, new _UO("Z", 0)); UTVerify2.CollectionsAreEqual(sourceList, collection); sourceList[0] = new _UO("ZZ", 0); sourceList.RemoveAt(sourceList.Count - 1); collection.Merge(sourceList, false, null); UTVerify2.CollectionsAreEqual(sourceList, collection); }