public async Task EventStoreStreamActor_Read_ExpectGetStateAsync() { var stateManager = new Mock <IActorStateManager>(); FakeEvent[] events = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() }; var state = new EventStoreStreamState(); state.Append(events); stateManager.Setup(manager => manager.GetStateAsync <EventStoreStreamState>(_stateName, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(state)) .Verifiable(); EventStoreStreamActor testDemoActor = await CreateActor(stateManager.Object, EventStoreStreamActor.CreateStreamId(events[0].AggregateType, events[0].AggregateId)); IList <IEvent> result = await testDemoActor.Read(); CheckValues(state.Read(), result); stateManager.VerifyAll(); }
public async Task EventStoreStreamActor_ReadAfterFive_ExpectFiveAfterEvents() { var stateManager = new Mock <IActorStateManager>(); FakeEvent[] testEvents1 = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() }; FakeEvent[] testEvents2 = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() }; var state = new EventStoreStreamState(); state.Append(testEvents1); state.Append(testEvents2); stateManager.Setup(manager => manager.GetStateAsync <EventStoreStreamState>(_stateName, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(state)) .Verifiable(); EventStoreStreamActor testDemoActor = await CreateActor(stateManager.Object, EventStoreStreamActor.CreateStreamId(testEvents1[0].AggregateType, testEvents1[0].AggregateId)); IList <IEvent> result = await testDemoActor.Read(testEvents1.Last().Id, 5); CheckValues(testEvents2.Take(5).ToList <IEvent>(), result); }