Example #1
0
        public void ACacheWithASingleEntryShouldAlwaysReturnThatEntry()
        {
            var cache = new InstanceCache <string>(1, UniqueStringCreator);

            var firstInstance = cache.GetNext();

            for (int i = 0; i < 100; i++)
            {
                Assert.AreEqual(firstInstance, cache.GetNext());
            }
        }
Example #2
0
        public void ACacheWithThreeeEntriesShouldAlwaysReturnThreeDistinctValues()
        {
            var cache = new InstanceCache <string>(3, UniqueStringCreator);

            var list = new List <string>();

            for (int i = 0; i < 100; i++)
            {
                list.Add(cache.GetNext());
            }

            int countOfDistinctEntries = list.Distinct().Count();

            Assert.AreEqual(countOfDistinctEntries, 3);
        }
Example #3
0
        public void TheInstanceCreatorMustReturnAValue()
        {
            var cache = new InstanceCache <string>(1, () => null);

            Assert.Throws <InvalidOperationException>(() => cache.GetNext());
        }