Ejemplo n.º 1
0
        public void TestUnEqualityByKvpKey()
        {
            var firstKey  = new CompositeCacheKey("Test1", new KeyValuePair <string, string>("key1", "value1"), new KeyValuePair <string, string>("key2", "value2"));
            var secondKey = new CompositeCacheKey("Test1", new KeyValuePair <string, string>("key23", "value1"), new KeyValuePair <string, string>("key2", "value2"));

            Assert.NotEqual(firstKey, secondKey);
            Assert.NotEqual(firstKey.GetHashCode(), secondKey.GetHashCode());
        }
Ejemplo n.º 2
0
        public void FunctionalDictionary()
        {
            var firstKey  = new CompositeCacheKey("Test1", new KeyValuePair <string, string>("key1", "value1"), new KeyValuePair <string, string>("key2", "value2"));
            var secondKey = new CompositeCacheKey("Test1", new KeyValuePair <string, string>("key23", "value1"), new KeyValuePair <string, string>("key2", "value2"));

            var dictionary = new[] { firstKey, secondKey }.ToImmutableDictionary(x => x, x => x.BaseCacheKey);

            Assert.True(dictionary.ContainsKey(firstKey));
            Assert.True(dictionary.ContainsKey(secondKey));

            var firstValue  = dictionary[firstKey];
            var secondValue = dictionary[secondKey];

            Assert.Equal(firstValue, firstKey.BaseCacheKey);
            Assert.Equal(secondValue, secondKey.BaseCacheKey);
        }