public void ExceptTest() { // ARRANGE var list1 = new[] { "a", "aa", "aaa", "aaaa" }; var list2 = new[] { "dd", "eeee" }; // ACT var except = list1.Except(list2, x => x.Length).ToList(); // ASSERT CollectionAssert.AreEqual(new[] { "a", "aaa" }, except); }
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()); }