public async Task get_reads_last_event() { _store.Setup(x => x.GetEventsBackwards(Moq.It.IsAny <string>(), StreamPosition.End, Moq.It.IsAny <int?>())) .Returns(Task.FromResult(_events)); var poco = await _pocoStore.Get <Poco>("test", "test", null).ConfigureAwait(false); Assert.AreEqual(0, poco.Item1); Assert.NotNull(poco.Item2); }
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 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)); }