Exemplo n.º 1
0
        public async void ClearAsync()
        {
            _store.Clear();
            _store.Add("Abc", new object());

            var cache = new FoobarCache("Foobar");
            await cache.SetAsync("123", new object());

            await cache.SetAsync("456", new object());

            await cache.SetAsync("789", new object());

            Assert.True(_store.Count > 1);
            await cache.ClearAsync();

            Assert.Equal("Abc", _store.Single().Key);
        }
Exemplo n.º 2
0
        public async void SetAsync()
        {
            _store.Clear();
            var cache  = new FoobarCache("Foobar");
            var valule = DateTime.Now;
            await cache.SetAsync("123", valule);

            Assert.Equal(valule, _store["FOOBAR.123"]);
            Assert.Equal("123", ((List <string>)_store["FOOBAR.KEYS"]).Single());
            Assert.Equal(typeof(DateTime).AssemblyQualifiedName, _store["FOOBAR.123.TYPE"]);

            await cache.ClearAsync();

            await cache.SetAsync("456", null);

            Assert.Equal(Cache.NullValue.Instance, _store["FOOBAR.456"]);
            Assert.Equal("456", ((List <string>)_store["FOOBAR.KEYS"]).Single());
            Assert.Equal(typeof(Cache.NullValue).AssemblyQualifiedName, _store["FOOBAR.456.TYPE"]);
        }