public void T09_RemoveItem_WhichIsInList() { Pet pet1 = new Pet() { Age = 10 }; Pet pet2 = new Pet() { Age = 7 }; Pet pet3 = new Pet() { Age = 1 }; Pet pet4 = new Pet() { Age = 8 }; Pet pet5 = new Pet() { Age = 11 }; SortableArrayList list = new SortableArrayList(); list.Add(pet1); list.Add(pet2); list.Add(pet3); list.Add(pet4); Assert.IsTrue(list.Remove(pet3), "Should return true"); Assert.AreEqual(3, list.Count(), "Count should be reduced"); }
public void T10_RemoveItem_WhichIsDuplicateInList() { Pet pet1 = new Pet() { Age = 10 }; Pet pet2 = new Pet() { Age = 7 }; Pet pet3 = new Pet() { Age = 1 }; Pet pet4 = new Pet() { Age = 8 }; Pet pet5 = new Pet() { Age = 11 }; SortableArrayList list = new SortableArrayList(); list.Add(pet1); list.Add(pet2); list.Add(pet3); list.Add(pet4); list.Add(pet3); Assert.IsTrue(list.Remove(pet3), "Should return true"); Assert.AreEqual(4, list.Count(), "Count should be reduced by 1"); Assert.AreEqual(pet3, list[3], "Second occurence of pet3 should not be deleted"); }
public void T08_RemoveItem_WhichIsNotInList() { Pet pet1 = new Pet() { Age = 10 }; Pet pet2 = new Pet() { Age = 7 }; Pet pet3 = new Pet() { Age = 1 }; Pet pet4 = new Pet() { Age = 8 }; Pet pet5 = new Pet() { Age = 11 }; SortableArrayList list = new SortableArrayList(); list.Add(pet1); list.Add(pet2); list.Add(pet3); list.Add(pet4); Assert.AreEqual(4, list.Count(), "Count not working properly"); Assert.IsFalse(list.Remove(pet5), "Remove should return false"); Assert.AreEqual(4, list.Count(), "Count should not be reduced, when no object is removed"); }