public void SqlServerEventStore_RetrieveEvents_PlainEvent_Should_Work()
        {
            var eventStore = new SqlServerEventStore(this.Settings, this.EventDispatcher);

            var aggId = Guid.NewGuid();

            var events = new[]
            {
                new PlainEvent(aggId, PlainEvent.TestEnum.Nope),
                new PlainEvent(aggId, null),
                new PlainEvent(Guid.NewGuid(), null),
                new PlainEvent(aggId, PlainEvent.TestEnum.Ok),
            };

            var eventsCount = events.Count(e => e.MyAggId == aggId);

            foreach (var @event in events)
            {
                eventStore.Save(@event);
            }

            var eventMapping = new EventMapping {
                AggregateIdPropertyName = nameof(PlainEvent.MyAggId), EventType = typeof(PlainEvent)
            };

            var eventDescriptors = new[] { eventMapping };

            var savedEvents = eventStore.RetrieveEvents(aggId, DateTime.Now, eventDescriptors, timelineId: null);

            Assert.NotNull(savedEvents);
            Assert.NotEmpty(savedEvents);
            Assert.True(savedEvents.All(e => e is PlainEvent));

            Assert.Equal(eventsCount, savedEvents.Count());
        }
        public void SqlServerEventStore_RetrieveEvents_ComplexEvent_Should_Work()
        {
            var eventStore = new SqlServerEventStore(this.Settings, this.EventDispatcher);

            var complexId = Guid.NewGuid();

            var events = new[]
            {
                new ComplexEvent(complexId, Environment.TickCount, "PROV@", new ComplexEvent.InternalProp(new List <string> {
                    "Hello", "Memento"
                }), byte.MaxValue),
                new ComplexEvent(complexId, 10000, "test titolo", new ComplexEvent.InternalProp(new List <string>()), byte.MinValue),
                new ComplexEvent(Guid.NewGuid(), 8787878, null, null, 0),
                new ComplexEvent(complexId, 12345, string.Empty, new ComplexEvent.InternalProp(new List <string> {
                    "test"
                }), 128),
            };

            var eventsCount = events.Count(e => e.ComplexId == complexId);

            foreach (var @event in events)
            {
                eventStore.Save(@event);
            }

            var eventMapping = new EventMapping {
                AggregateIdPropertyName = nameof(ComplexEvent.ComplexId), EventType = typeof(ComplexEvent)
            };

            var eventDescriptors = new[] { eventMapping };

            var savedEvents = eventStore.RetrieveEvents(complexId, DateTime.Now, eventDescriptors, timelineId: null);

            Assert.NotNull(savedEvents);
            Assert.NotEmpty(savedEvents);
            Assert.True(savedEvents.All(e => e is ComplexEvent));

            Assert.Equal(eventsCount, savedEvents.Count());
        }