public void RemoveCallsGrain()
        {
            var key     = Guid.NewGuid().ToString();
            var factory = Mock.Of <IGrainFactory>(x => x.GetGrain <ICacheGrain>(key, null).RemoveAsync() == Task.CompletedTask);
            var clock   = new NullClock();
            var cache   = new OutkeepDistributedCache(factory, clock);

            cache.Remove(key);

            Mock.Get(factory).VerifyAll();
        }
        public async Task RefreshAsyncCallsGrain()
        {
            var key     = Guid.NewGuid().ToString();
            var factory = Mock.Of <IGrainFactory>(x => x.GetGrain <ICacheGrain>(key, null).RefreshAsync() == Task.CompletedTask);
            var clock   = new NullClock();
            var cache   = new OutkeepDistributedCache(factory, clock);

            await cache.RefreshAsync(key).ConfigureAwait(false);

            Mock.Get(factory).VerifyAll();
        }
        public void GetCallsGrain()
        {
            var key     = Guid.NewGuid().ToString();
            var value   = Guid.NewGuid().ToByteArray();
            var factory = Mock.Of <IGrainFactory>(x => x.GetGrain <ICacheGrain>(key, null).GetAsync() == new ValueTask <CachePulse>(new CachePulse(Guid.NewGuid(), value)));
            var clock   = new NullClock();
            var cache   = new OutkeepDistributedCache(factory, clock);

            var result = cache.Get(key);

            Assert.Same(value, result);
            Mock.Get(factory).VerifyAll();
        }
        public async Task SetAsyncCallsGrainWithNoExpiration()
        {
            var key               = Guid.NewGuid().ToString();
            var value             = Guid.NewGuid().ToByteArray();
            var slidingExpiration = TimeSpan.FromMinutes(1);
            var factory           = Mock.Of <IGrainFactory>(x => x.GetGrain <ICacheGrain>(key, null).SetAsync(new Immutable <byte[]?>(value), null, slidingExpiration) == Task.CompletedTask);
            var clock             = new NullClock();
            var cache             = new OutkeepDistributedCache(factory, clock);

            var options = new DistributedCacheEntryOptions
            {
                SlidingExpiration = slidingExpiration
            };
            await cache.SetAsync(key, value, options).ConfigureAwait(false);

            Mock.VerifyAll();
        }
        public void SetCallsGrain()
        {
            var key   = Guid.NewGuid().ToString();
            var value = Guid.NewGuid().ToByteArray();
            var absoluteExpiration = DateTimeOffset.UtcNow.AddHours(1);
            var slidingExpiration  = TimeSpan.FromMinutes(1);
            var factory            = Mock.Of <IGrainFactory>(x => x.GetGrain <ICacheGrain>(key, null).SetAsync(new Immutable <byte[]?>(value), absoluteExpiration, slidingExpiration) == Task.CompletedTask);
            var clock = new NullClock();
            var cache = new OutkeepDistributedCache(factory, clock);

            var options = new DistributedCacheEntryOptions
            {
                AbsoluteExpiration = absoluteExpiration,
                SlidingExpiration  = slidingExpiration
            };

            cache.Set(key, value, options);

            Mock.VerifyAll();
        }