public void SetItemCount_ExpectedCountMisMatch_DoesNotUpdate() { IMultiSet <string> multiSet = new MultiSet <string>(); multiSet.Add("item", 3); Assert.IsFalse(multiSet.SetItemCount("item", 4, 5)); Assert.IsFalse(multiSet.SetItemCount("item", 0, 5)); Assert.IsFalse(multiSet.SetItemCount("itemNotExist", 1, 5)); Assert.IsFalse(multiSet.SetItemCount("itemNotExist", 5, 5)); Assert.AreEqual(3, multiSet.Count(i => i == "item")); Assert.IsFalse(multiSet.Any(i => i == "itemNotExist")); }
public void Remove() { IMultiSet <string> multiSet = new MultiSet <string>(); multiSet.Add("itemToDecrease", 3); multiSet.Add("itemToDelete", 3); multiSet.Add("itemToDelete_negative", 3); multiSet.Add("itemNotChanged", 3); Assert.AreEqual(3, multiSet.Remove("itemToDecrease", 1)); Assert.IsTrue(multiSet.Remove("itemToDecrease")); Assert.AreEqual(3, multiSet.Remove("itemToDelete", 3)); Assert.IsFalse(multiSet.Remove("itemToDelete")); Assert.AreEqual(3, multiSet.Remove("itemToDelete_negative", 4)); Assert.AreEqual(3, multiSet.Remove("itemNotChanged", 0)); Assert.AreEqual(0, multiSet.Remove("itemNotExist", 1)); Assert.IsFalse(multiSet.Remove("itemNotExist")); Assert.AreEqual(1, multiSet.Count(i => i == "itemToDecrease")); Assert.AreEqual(3, multiSet.Count(i => i == "itemNotChanged")); Assert.IsFalse(multiSet.Any(i => i == "itemToDelete")); Assert.IsFalse(multiSet.Any(i => i == "itemToDelete_negative")); Assert.IsFalse(multiSet.Any(i => i == "itemNotExist")); }
public void SetItemCount() { IMultiSet <string> multiSet = new MultiSet <string>(); multiSet.Add("itemToIncrease", 3); multiSet.Add("itemToDecrease", 3); multiSet.Add("itemToDelete", 3); multiSet.Add("itemNotChanged", 3); Assert.AreEqual(3, multiSet.SetItemCount("itemToIncrease", 4)); Assert.AreEqual(3, multiSet.SetItemCount("itemToDecrease", 2)); Assert.AreEqual(3, multiSet.SetItemCount("itemToDelete", 0)); Assert.AreEqual(3, multiSet.SetItemCount("itemNotChanged", 3)); Assert.AreEqual(0, multiSet.SetItemCount("itemToAdd", 3)); Assert.AreEqual(4, multiSet.Count(i => i == "itemToIncrease")); Assert.AreEqual(2, multiSet.Count(i => i == "itemToDecrease")); Assert.IsFalse(multiSet.Any(i => i == "itemToDelete")); Assert.AreEqual(3, multiSet.Count(i => i == "itemToAdd")); Assert.AreEqual(3, multiSet.Count(i => i == "itemNotChanged")); }