예제 #1
0
        public static void Strategy()
        {
            var initial = new[] {0, 1, 2, 3, 4, 5, 6, 7};
            var toRemove = new[] {2, 3, 5};
            IResizer resizeStrategy = new ExactResizer();
            var collection = new ArrayBasedCollection<int>(resizeStrategy);

            foreach (int element in initial)
            {
                collection.Add(element);
            }

            foreach (int elementToRemove in toRemove)
            {
                collection.Remove(elementToRemove);
            }

            collection.Clear();
        }
예제 #2
0
        public static void Strategy()
        {
            var      initial        = new[] { 0, 1, 2, 3, 4, 5, 6, 7 };
            var      toRemove       = new[] { 2, 3, 5 };
            IResizer resizeStrategy = new ExactResizer();
            var      collection     = new ArrayBasedCollection <int>(resizeStrategy);

            foreach (int element in initial)
            {
                collection.Add(element);
            }

            foreach (int elementToRemove in toRemove)
            {
                collection.Remove(elementToRemove);
            }

            collection.Clear();
        }
        public void Test_Add_Remove(IResizer resizeStrategy)
        {
            var initial = new[] {0, 1, 2, 3, 4, 5, 6, 7};
            var toRemove = new[] {2, 3, 5};
            var collection = new ArrayBasedCollection<int>(resizeStrategy);

            foreach (int element in initial)
            {
                collection.Add(element);
            }
            CollectionAssert.AreEquivalent(initial, collection.ToArray());

            foreach (int elementToRemove in toRemove)
            {
                collection.Remove(elementToRemove);
            }

            int[] expected = initial.Except(toRemove).ToArray();
            CollectionAssert.AreEquivalent(expected, collection.ToArray());

            collection.Clear();
            int[] emptyArray = Enumerable.Empty<int>().ToArray();
            CollectionAssert.AreEquivalent(emptyArray, collection.ToArray());
        }
예제 #4
0
        public void Test_Add_Remove(IResizer resizeStrategy)
        {
            var initial    = new[] { 0, 1, 2, 3, 4, 5, 6, 7 };
            var toRemove   = new[] { 2, 3, 5 };
            var collection = new ArrayBasedCollection <int>(resizeStrategy);

            foreach (int element in initial)
            {
                collection.Add(element);
            }
            CollectionAssert.AreEquivalent(initial, collection.ToArray());

            foreach (int elementToRemove in toRemove)
            {
                collection.Remove(elementToRemove);
            }

            int[] expected = initial.Except(toRemove).ToArray();
            CollectionAssert.AreEquivalent(expected, collection.ToArray());

            collection.Clear();
            int[] emptyArray = Enumerable.Empty <int>().ToArray();
            CollectionAssert.AreEquivalent(emptyArray, collection.ToArray());
        }