Exemplo n.º 1
0
        public async Task SameTypeSameKey()
        {
            var setCatA = new Utilities.One.Cat {
                Name = "Linq"
            };
            await CacheRepository.SetByTypeAsync(1, setCatA);

            var setCatB = new Utilities.One.Cat {
                Name = "Sql"
            };
            await CacheRepository.SetByTypeAsync(1, setCatB);

            var getCat = await CacheRepository.GetByTypeAsync <Utilities.One.Cat>(1);

            Assert.Equal(setCatB.Name, getCat.Name);

            Assert.Equal(1, MemoryCacheRepository.Map.Count);
        }
Exemplo n.º 2
0
        public async Task SameKeyDifferentType()
        {
            var setCat = new Utilities.One.Cat {
                Name = "Linq"
            };
            await CacheRepository.SetByTypeAsync(1, setCat);

            var setDog = new Utilities.One.Dog {
                Name = "Taboo"
            };
            await CacheRepository.SetByTypeAsync(1, setDog);

            var getCat = await CacheRepository.GetByTypeAsync <Utilities.One.Cat>(1);

            Assert.Equal(setCat.Name, getCat.Name);

            var getDog = await CacheRepository.GetByTypeAsync <Utilities.One.Dog>(1);

            Assert.Equal(setDog.Name, getDog.Name);

            Assert.Equal(2, MemoryCacheRepository.Map.Count);
        }
Exemplo n.º 3
0
        public async Task SameTypeDifferentNamespace()
        {
            var setCat1 = new Utilities.One.Cat {
                Name = "Linq"
            };
            await CacheRepository.SetByTypeAsync(1, setCat1);

            var setCat2 = new Utilities.Two.Cat {
                Name = "Sql"
            };
            await CacheRepository.SetByTypeAsync(1, setCat2);

            var getCat1 = await CacheRepository.GetByTypeAsync <Utilities.One.Cat>(1);

            Assert.Equal(setCat1.Name, getCat1.Name);

            var getCat2 = await CacheRepository.GetByTypeAsync <Utilities.Two.Cat>(1);

            Assert.Equal(setCat2.Name, getCat2.Name);

            Assert.Equal(2, MemoryCacheRepository.Map.Count);
        }