public void AddRemove() { Assert.NotNull(intColA); Assert.NotNull(intColB); const int Items = 10; const int ItemIndexToRemove = 3; const int ValueToRemove = 1; const int ValueToAddUnique = ValueToRemove; const int ValueToAddDups = ValueToAddUnique; const int MinBVal = 7; const int SizeAAfterBRem = Items - (Items - MinBVal); //add items ensure indicies match for (int i = 0; i < Items; i++) { //added at expected index Assert.AreEqual(i, intColA.Add(i)); //value at index matches expected value Assert.AreEqual(i, intColA.Get(i)); } //ensure count matches items added Assert.AreEqual(Items, intColA.Count); var valAtRemoveIndex = intColA.GetSafe(ItemIndexToRemove); intColA.RemoveAt(ItemIndexToRemove); Assert.AreEqual(Items - 1, intColA.Count); intColA.Insert(ItemIndexToRemove, valAtRemoveIndex); Assert.AreEqual(valAtRemoveIndex, intColA.GetSafe(ItemIndexToRemove)); intColA.Remove(ValueToRemove); Assert.AreEqual(Items - 1, intColA.Count); //multiple calls to add unique to get back the value we removed and ensure unique works for (int i = 0; i < Items; i++) { intColA.AddUnique(ValueToAddUnique); } Assert.AreEqual(Items, intColA.Count); //now add a bunch of dups, so we can remove all of them for (int i = 0; i < Items; i++) { intColA.Add(ValueToAddDups); } intColA.RemoveAll(ValueToAddDups); Assert.AreEqual(Items - 1, intColA.Count); //put it back intColA.Add(ValueToAddDups); //now add a bunch of items to the colB and remove all of them from colA for (int i = MinBVal; i < Items; i++) { intColB.Add(i); } intColA.RemoveAll(intColB); Assert.AreEqual(intColA.Count, SizeAAfterBRem);// all of b should be gone intColA.Add(intColB.Get(0)); intColA.AddUnique(intColB); //ensure intColB[0] doesn't double Assert.AreEqual(intColA.Count, Items); // all of b should be back in there now intColA.Add(intColB); intColA.Unique(); Assert.IsTrue(intColA.Count == Items); intColA.RemoveAll(intColA);//should be equiv to clear intColB.Clear(); Assert.AreEqual(intColA.Count, 0); Assert.AreEqual(intColB.Count, 0); intColA.Clear(); intColB.Clear(); }