public void Remove_DecrementsDuplicateCount() { var bag = new CountingBag <int>(new[] { int.MaxValue, int.MaxValue }); var count = bag.GetCountFor(int.MaxValue); bag.Remove(int.MaxValue); Expect.The(bag.GetCountFor(int.MaxValue)).ToEqual(count - 1); }
public void Remove_DecrementsTotalCount() { var bag = new CountingBag <int>(new[] { 1, 2, 3 }); var count = bag.Count; bag.Remove(2); Expect.The(bag.Count).ToEqual(count - 1); }
public void Remove_RemovesAnItem() { var bag = new CountingBag <string>(new[] { "foo", "bar" }); Expect.The(bag).ToContain("bar"); bag.Remove("bar"); Expect.The(bag).Not.ToContain("bar"); }
/// <summary> /// Expect the enumerable to contain only the given items, using the /// given equality comparer. /// </summary> /// <param name="expected"> /// The expected items. /// </param> /// <param name="comparer"> /// The comparer used to determine item membership. /// </param> public virtual bool ToContainExactly(IEnumerable <TItem> expected, IEqualityComparer <TItem> comparer) { var bag = new CountingBag <TItem>(actual, comparer); if (expected.Any(item => !bag.Remove(item))) { return(false); } return(bag.Count == 0); }
public void Remove_DecrementsDuplicateCount() { var bag = new CountingBag<int>(new[] { int.MaxValue, int.MaxValue }); var count = bag.GetCountFor(int.MaxValue); bag.Remove(int.MaxValue); Expect.The(bag.GetCountFor(int.MaxValue)).ToEqual(count - 1); }
public void Remove_WhenNoItemRemoved_ReturnsFalse() { var bag = new CountingBag<int>(new[] { 1 }); Expect.The(bag.Remove(0)).ToBeFalse(); }
public void Remove_WhenItemIsRemoved_ReturnsTrue() { var bag = new CountingBag<int>(new[] { 0 }); Expect.The(bag.Remove(0)).ToBeTrue(); }
public void Remove_RemovesAnItem() { var bag = new CountingBag<string>(new[] { "foo", "bar" }); Expect.The(bag).ToContain("bar"); bag.Remove("bar"); Expect.The(bag).Not.ToContain("bar"); }
public void Remove_DecrementsTotalCount() { var bag = new CountingBag<int>(new[] { 1, 2, 3 }); var count = bag.Count; bag.Remove(2); Expect.The(bag.Count).ToEqual(count - 1); }
public void Remove_WhenNoItemRemoved_ReturnsFalse() { var bag = new CountingBag <int>(new[] { 1 }); Expect.The(bag.Remove(0)).ToBeFalse(); }
public void Remove_WhenItemIsRemoved_ReturnsTrue() { var bag = new CountingBag <int>(new[] { 0 }); Expect.The(bag.Remove(0)).ToBeTrue(); }