Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }