Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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");
        }