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

            result.Should().NotBeNull();
            result.Count.Should().Be(0);
        }
Example #2
0
        public void StateReadAfterUnknown_ExpectException()
        {
            FakeEvent[] testEvents = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() };
            var         store      = new EventStoreStreamState();

            store.Append(testEvents);
            Invoking(() => store.Read(Guid.NewGuid())).Should().Throw <ArgumentException>();
        }
Example #3
0
        public void StateReadFiveEvents_ExpectFiveEvents()
        {
            FakeEvent[] testEvents = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() };
            var         store      = new EventStoreStreamState();

            store.Append(testEvents);
            IList <IEvent> result = store.Read(null, 5);

            CheckValues(testEvents.Take(5).ToList <IEvent>(), result);
        }
Example #4
0
        public void EmptyStateAppend_ExpectSameList()
        {
            FakeEvent[] testEvents = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() };
            var         store      = new EventStoreStreamState();

            store.Append(testEvents);
            IList <IEvent> result = store.Read();

            CheckValues(testEvents, result);
        }
Example #5
0
        public void StateReadFiveAfter_ExpectFiveAfterEvents()
        {
            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         store       = new EventStoreStreamState();

            store.Append(testEvents1);
            store.Append(testEvents2);
            IList <IEvent> result = store.Read(testEvents1.Last().Id, 5);

            CheckValues(testEvents2.Take(5).ToList <IEvent>(), result);
        }
Example #6
0
        public void StateAppend_ExpectSumList()
        {
            FakeEvent[] testEvents = new[] { new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent(), new FakeEvent() };
            var         store      = new EventStoreStreamState();

            store.Append(testEvents.Take(4).ToList <IEvent>());
            store.Append(testEvents.Skip(4).Take(2).ToList <IEvent>());
            store.Append(testEvents.Skip(6).ToList <IEvent>());
            IList <IEvent> result = store.Read();

            CheckValues(testEvents, result);
        }
        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);
        }