public void CountedSetTryGetCountReturnsFalseIfItemIsNotPresent()
        {
            var set = new CountedSet <string>();

            bool result = set.TryGetCount("foo", out _);

            Assert.IsFalse(result);
        }
        public void CountedSetTryGetCountReturnsZeroIfItemIsNotPresent()
        {
            var set = new CountedSet <string>();

            int count;

            Assert.IsFalse(set.TryGetCount("foo", out count));
            Assert.AreEqual(0, count);
        }
        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);
        }
        public void IfItemIsAddedToSetOnceAssociatedCountIsOne()
        {
            int count = 0;
            var set   = new CountedSet <string>();

            set.Add("foo");
            set.TryGetCount("foo", out count);

            Assert.AreEqual(1, count);
        }
        public void CountedSetMaintainsDistinctCountForDifferentItems()
        {
            int fooCount = 0;
            int barCount = 0;

            var set = new CountedSet <string>();

            set.Add("foo");
            set.Add("foo");
            set.Add("foo");
            set.Add("bar");
            set.Add("bar");

            set.TryGetCount("foo", out fooCount);
            set.TryGetCount("bar", out barCount);

            Assert.AreEqual(3, fooCount);
            Assert.AreEqual(2, barCount);
        }
        public void IfItemIsAddedToSetMultipleTimesAssociatedCountIsIncreasedByOne()
        {
            int firstCount  = 0;
            int secondCount = 0;
            int thirdCount  = 0;

            var set = new CountedSet <string>();

            //add first time
            set.Add("foo");
            set.TryGetCount("foo", out firstCount);

            //add second time
            set.Add("foo");
            set.TryGetCount("foo", out secondCount);

            //add third time
            set.Add("foo");
            set.TryGetCount("foo", out thirdCount);

            Assert.AreEqual(1, firstCount);
            Assert.AreEqual(2, secondCount);
            Assert.AreEqual(3, thirdCount);
        }