Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }