public static void ShouldBeSet <TCacheKey, TInstance>(this CachingFactory factory, TCacheKey cacheKey, TInstance instance)
            where TInstance : class
            where TCacheKey : ICacheKey
        {
            var provider = ((CachingInit)factory.TryGetValue("init")).Provider;

            Mock.Get(provider).Verify(r => r.Set(Pleasure.MockIt.Is <TCacheKey>(key => key.GetName().ShouldEqual(cacheKey.GetName())), Pleasure.MockIt.IsStrong(instance)));
        }
        public static void ShouldBeGet <TInstance, TCacheKey>(this CachingFactory factory, TCacheKey cacheKey)
            where TCacheKey : ICacheKey
            where TInstance : class, new()
        {
            var provider = ((CachingInit)factory.TryGetValue("init")).Provider;

            Mock.Get(provider).Verify(r => r.Get <TInstance>(Pleasure.MockIt.Is <string>(key => key.ShouldEqual(cacheKey.GetName()))));
        }
Пример #3
0
        public void ZeroHash()
        {
            var cache = new CachingFactory<CacheKey, CacheValue>(512,
                k => new CacheValue(k.Value + 1),
                k => k.Value,
                (k, v) => k.Value == v.Value);

            var key = new CacheKey(0);
            Assert.Equal(CacheKey.GetHashCode(key), 0);

            CacheValue value;
            bool found = cache.TryGetValue(key, out value);
            Assert.False(found);
        }
Пример #4
0
        public void ZeroHash()
        {
            var cache = new CachingFactory <CacheKey, CacheValue>(512,
                                                                  k => new CacheValue(k.Value + 1),
                                                                  k => k.Value,
                                                                  (k, v) => k.Value == v.Value);

            var key = new CacheKey(0);

            Assert.Equal(CacheKey.GetHashCode(key), 0);

            CacheValue value;
            bool       found = cache.TryGetValue(key, out value);

            Assert.False(found);
        }
        public static void ShouldBeDelete <TCacheKey>(this CachingFactory factory, TCacheKey cacheKey) where TCacheKey : ICacheKey
        {
            var provider = ((CachingInit)factory.TryGetValue("init")).Provider;

            Mock.Get(provider).Verify(r => r.Delete(Pleasure.MockIt.Is <TCacheKey>(key => key.GetName().ShouldEqual(cacheKey.GetName()))));
        }