예제 #1
0
        public void TryGetBatchTwiceFromEventStoreWithSingleEventAndDifferentDispatchers()
        {
            // arrange
            var eventDispatcherEventStore = new SqlServerEventDispatcherEventStore(this.ConnectionString);
            var eventStore = new SqlServerEventStore(this.ConnectionString);
            var streamId   = Guid.NewGuid();
            var events     = new[]
            {
                new Event {
                    Id = 3, Value = "Three"
                },
            };

            string commitState;

            eventStore.CommitStream(streamId, events, Guid.NewGuid(), null, out commitState);

            // act
            var firstBatch  = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.NewGuid(), 50);
            var secondBatch = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.NewGuid(), 50);

            // assert
            firstBatch.Should().NotBeNull();
            firstBatch.Events.Should().ContainSingle(@event => @event.Payload.As <Event>().Id == 3 && @event.Payload.As <Event>().Value == "Three");
            secondBatch.Should().NotBeNull();
            secondBatch.Events.Should().ContainSingle(@event => @event.Payload.As <Event>().Id == 3 && @event.Payload.As <Event>().Value == "Three");
        }
예제 #2
0
        public void TryGetMultipleBatchesFromEventStoreWithManyEvents()
        {
            // arrange
            var eventDispatcherEventStore = new SqlServerEventDispatcherEventStore(this.ConnectionString);
            var eventStore = new SqlServerEventStore(this.ConnectionString);
            var streamId   = Guid.NewGuid();
            var events     = new[]
            {
                new Event {
                    Id = 4, Value = "Four"
                },
                new Event {
                    Id = 5, Value = "Five"
                },
                new Event {
                    Id = 6, Value = "Six"
                },
            };

            string commitState;

            eventStore.CommitStream(streamId, events, Guid.NewGuid(), null, out commitState);

            // act
            var firstBatch  = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.Empty, 2);
            var secondBatch = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.Empty, 2);

            // assert
            firstBatch.Should().NotBeNull();
            firstBatch.Events.Should().Contain(@event => @event.Payload.As <Event>().Id == 4 && @event.Payload.As <Event>().Value == "Four");
            firstBatch.Events.Should().Contain(@event => @event.Payload.As <Event>().Id == 5 && @event.Payload.As <Event>().Value == "Five");
            secondBatch.Should().NotBeNull();
            secondBatch.Events.Should().ContainSingle(@event => @event.Payload.As <Event>().Id == 6 && @event.Payload.As <Event>().Value == "Six");
        }
예제 #3
0
        public void TryGetBatchFromEmptyEventStore()
        {
            // arrange
            var eventDispatcherEventStore = new SqlServerEventDispatcherEventStore(this.ConnectionString);

            // act
            var batch = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.Empty, 50);

            // assert
            batch.Should().BeNull();
        }
예제 #4
0
        public void TryGetBatchFromEventStoreWithSingleEvent()
        {
            // arrange
            var eventDispatcherEventStore = new SqlServerEventDispatcherEventStore(this.ConnectionString);
            var eventStore = new SqlServerEventStore(this.ConnectionString);
            var streamId   = Guid.NewGuid();
            var events     = new[]
            {
                new Event {
                    Id = 1, Value = "One"
                },
            };

            string commitState;

            eventStore.CommitStream(streamId, events, Guid.NewGuid(), null, out commitState);

            // act
            var batch = eventDispatcherEventStore.GetNextUndispatchedEventsBatch(Guid.Empty, 50);

            // assert
            batch.Should().NotBeNull();
            batch.Events.Should().ContainSingle(@event => @event.Payload.As <Event>().Id == 1 && @event.Payload.As <Event>().Value == "One");
        }