public void adding_duplicate_keys_should_replace_value() { RandomCache cache = new RandomCache(10); string key = "key1"; string value = "value1"; cache.Add(key, value); cache.Exists(key).ShouldBeTrue(); cache.Get(key).ShouldEqual(value); value = "some new value"; cache.Add(key, value); cache.Get(key).ShouldEqual(value); }
public void Should_be_able_to_add_to_a_new_cache() { RandomCache cache = new RandomCache(10); string key = "key1"; string value = "value1"; cache.Add(key, value); cache.Exists(key).ShouldBeTrue(); }
private static void RunOneTest(Dictionary<string, int> testResults) { RandomCache cache = new RandomCache(3); cache.Add("key1", "value1"); cache.Add("key2", "value2"); cache.Add("key3", "value3"); // the fourth add should cause one of the first three items to be removed. Spec isn't clear // whether removing a random item could include the item just added. I decided it should not. cache.Add("key4", "value4"); updateTestResults(testResults, cache, "key1"); updateTestResults(testResults, cache, "key2"); updateTestResults(testResults, cache, "key3"); }