public async Task get_tries_cache_misses() { _pocoStore = new Aggregates.Internal.StorePocos(_store.Object, _cache.Object, true, (a, b, c, d, e) => "test"); _cache.Setup(x => x.Retreive("test")).Returns(() => null); var poco = await _pocoStore.Get <Poco>("test", "test", null).ConfigureAwait(false); Assert.Null(poco); }
public void Setup() { _store = new Moq.Mock <IStoreEvents>(); _cache = new Moq.Mock <ICache>(); _pocoStore = new Aggregates.Internal.StorePocos(_store.Object, _cache.Object, false, (a, b, c, d, e) => "test"); var @event = new Moq.Mock <IFullEvent>(); @event.Setup(x => x.Event).Returns(new Poco()); @event.Setup(x => x.Descriptor.Version).Returns(0); _events = new[] { @event.Object }; }
public async Task get_tries_cache_is_deep_copy() { _pocoStore = new Aggregates.Internal.StorePocos(_store.Object, _cache.Object, true, (a, b, c, d, e) => "test"); _cache.Setup(x => x.Retreive("test")).Returns(new Tuple <long, Poco>(0, new Poco())); var poco = await _pocoStore.Get <Poco>("test", "test", null).ConfigureAwait(false); Assert.NotNull(poco.Item2); poco.Item2.Foo = "test"; // Verify the change we made above is not reflected in the cache immediately // (a unit of work save should update or evict cache) var poco2 = await _pocoStore.Get <Poco>("test", "test", null).ConfigureAwait(false); Assert.NotNull(poco2.Item2); Assert.True(string.IsNullOrEmpty(poco2.Item2.Foo)); }