public async Task Should_read_from_store() { A.CallTo(() => store.ReadAsync <int>(key)) .Returns((123, Guid.NewGuid().ToString())); var actual = await sut.GetAsync <MyStatefulObject, int>(key); Assert.Same(state, actual); Assert.NotNull(cache.Get <object>(key)); Assert.Equal(123, state.State); }
public async Task ReadAsync() { (State, etag) = await store.ReadAsync <T>(key); if (Equals(State, default(T))) { State = Activator.CreateInstance <T>(); } }
public static async Task <VisualObject> ReadObjectAsync( IStateStore stateStore, CancellationToken cancellationToken) { try { return(await stateStore.ReadAsync(cancellationToken)); } catch (Exception e) { Console.WriteLine($"Error in reading the object. {e.ToString()}"); return(null); } }
private async Task ReadStateAsync() { var storableState = await _stateStore.ReadAsync(_key); if (storableState != null) { Version = storableState.Version; State = _dataSerializer.Deserialize <TState>(storableState.Payload); } var hasMoreResults = false; do { var slice = await _eventStore.ReadAsync(_key, Version + 1); hasMoreResults = slice.HasMoreResults; if (slice.Events.Any()) { ApplyEvents(slice.Events.Select(ToVersionedEvent)); } } while (hasMoreResults); }