public async Task SubscriberUpdate_ItemAdded()
        {
            A.CallTo(() => _subscriber.GetAsync("a", A <Type> .Ignored)).Returns("b");
            _subscriber.CacheUpdate += Raise.With(this, new CacheUpdateNotificationArgs {
                Key = "a", Type = typeof(string).AssemblyQualifiedName
            });

            await Task.Delay(TimeSpan.FromSeconds(1));

            A.CallTo(() => _decoratedCache.Add <object>("a", "b"))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #2
0
        private async Task CacheUpdateAction(object sender, CacheUpdateNotificationArgs e)
        {
            var remoteItem = await _cacheSubscriber.GetAsync(e.Key, _knownTypes.GetOrAdd(e.Type, Type.GetType(e.Type)));

            if (e.SpecificTimeToLive != null)
            {
                Add(e.Key, remoteItem, e.SpecificTimeToLive._timeToLive);
            }
            else
            {
                Add(e.Key, remoteItem);
            }
        }
        private async Task CacheUpdateAction(object sender, CacheUpdateNotificationArgs e)
        {
            var remoteItem = await _cacheSubscriber.GetAsync(e.Key, _knownTypes.GetOrAdd(e.Type, Type.GetType(e.Type)));

            Add(e.Key, remoteItem);
        }