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()); } }
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); }
public void TheInstanceCreatorMustReturnAValue() { var cache = new InstanceCache <string>(1, () => null); Assert.Throws <InvalidOperationException>(() => cache.GetNext()); }