public void RemoveReturnsFalseIfSetDoesNotContainItem() { var set = new CountedSet <string>(); bool result = set.Remove("foo"); Assert.IsFalse(result); }
public void IfItemIsAddedToSetOnceRemoveCompletelyRemovesItem() { var set = new CountedSet <string>(); set.Add("foo"); set.Remove("foo"); Assert.IsFalse(set.Contains("foo")); }
public void IfItemIsAddedToSetMultipleTimesRemoveDoesNotCompletelyRemoveItem() { var set = new CountedSet <string>(); set.Add("foo"); set.Add("foo"); set.Remove("foo"); Assert.IsTrue(set.Contains("foo")); }
public void IfItemIsAddedToSetMutlipleTimesItMustBeRemovedAnEqualNumberOfTimes() { bool firstCheck = false; bool secondCheck = false; bool thirdCheck = false; var set = new CountedSet <string>(); set.Add("foo"); set.Add("foo"); set.Add("foo"); set.Remove("foo"); firstCheck = set.Contains("foo"); set.Remove("foo"); secondCheck = set.Contains("foo"); set.Remove("foo"); thirdCheck = set.Contains("foo"); Assert.IsTrue(firstCheck); Assert.IsTrue(secondCheck); Assert.IsFalse(thirdCheck); }
public void IfItemIsAddedToSetMultipleTimesRemoveReducesCountByOne() { int firstCount = 0; int secondCount = 0; var set = new CountedSet <string>(); set.Add("foo"); set.Add("foo"); set.TryGetCount("foo", out firstCount); set.Remove("foo"); set.TryGetCount("foo", out secondCount); Assert.AreEqual(2, firstCount); Assert.AreEqual(1, secondCount); }