Beispiel #1
0
        public async Task CacheMethod_Method_GetValue_IgnoreParameter()
        {
            string url  = "http://www.google.com";
            string url2 = "http://www.cnn.com";

            var cache = CreateCache();

            CacheStrategyAsync <string> strat1 = cache.Method(t => t.DownloadTextAsync(Parameter.DoNotCache(url)));

            CacheStrategyAsync <string> strat2 = cache.Method(t => t.DownloadTextAsync(Parameter.DoNotCache(url2)));

            Assert.AreEqual(strat1.Key, strat2.Key, "Both strategies should have the same key because the parameter should be ignored");

            string result = await strat1.GetValueAsync();

            strat1.ClearValue();

            string result2 = await strat2.GetValueAsync();

            Assert.AreNotEqual(result, result2, "These should have returned different results because the parameter values were different");
        }
Beispiel #2
0
        public async Task CacheMethod_Method_GetValue_IgnoreParameter()
        {
            string arg1 = "hello";
            string arg2 = "world";

            var cache = CreateCache();

            CacheStrategyAsync <string> strat1 = cache.Method(t => t.MethodAsync(Parameter.DoNotCache(arg1)));

            CacheStrategyAsync <string> strat2 = cache.Method(t => t.MethodAsync(Parameter.DoNotCache(arg2)));

            Assert.AreEqual(strat1.Key, strat2.Key, "Both strategies should have the same key because the parameter should be ignored");

            string result = await strat1.GetValueAsync();

            strat1.ClearValue();

            string result2 = await strat2.GetValueAsync();

            Assert.AreNotEqual(result, result2, "These should have returned different results because the parameter values were different");
        }