示例#1
0
        public void NewState_ExpectEmptyList()
        {
            IList <IEvent> result = new EventStoreStreamState().Read();

            result.Should().NotBeNull();
            result.Count.Should().Be(0);
        }
        public async Task EventStoreStreamActor_GetState_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));

            EventStoreStreamState result = (EventStoreStreamState)await testDemoActor.GetStateValue();

            result.Should().Be(state);

            stateManager.VerifyAll();
        }