public void SaveEvents_NullObject_ShouldThrowException()
        {
            // Arrange
            IComparer <Event>         comparer   = CreateEventComparer();
            IEventStore <uint, Event> eventStore = new MemoryEventStore <uint, Event>(comparer);

            // Act, Assert
            Assert.Throws <ArgumentNullException>(() => eventStore.SaveEvents(1, null));
        }
        public void SaveEvents_WithNotEmptyArray_ShouldReturnTrue()
        {
            // Arrange
            Event[]                   fakeEvents = { new FakeEvent() };
            IComparer <Event>         comparer   = CreateEventComparer();
            IEventStore <uint, Event> eventStore = new MemoryEventStore <uint, Event>(comparer);

            // Act
            bool result = eventStore.SaveEvents(1, fakeEvents);

            // Assert
            Assert.True(result);
        }
        public void GetEventsById_WithExistingId_ShouldReturnEventCollection()
        {
            // Arrange
            uint eventAggregateId = 1;

            Event[]                   fakeEvents = { new FakeEvent() };
            IComparer <Event>         comparer   = CreateEventComparer();
            IEventStore <uint, Event> eventStore = new MemoryEventStore <uint, Event>(comparer);

            // Act
            eventStore.SaveEvents(eventAggregateId, fakeEvents);
            IEnumerable <Event> result = eventStore.GetEventsById(eventAggregateId);

            // Assert
            Assert.NotNull(result);
            Assert.Single(result);
        }
        public void GetEventsById_WithUnexistingId_ShouldReturnEmptyCollection()
        {
            // Arrange
            uint eventAggregateId = 1;

            Event[]                   fakeEvents = { new FakeEvent() };
            IComparer <Event>         comparer   = CreateEventComparer();
            IEventStore <uint, Event> eventStore = new MemoryEventStore <uint, Event>(comparer);

            eventStore.SaveEvents(eventAggregateId, fakeEvents);

            // Act
            IReadOnlyCollection <Event> result = eventStore.GetEventsById(2);

            // Assert
            Assert.Empty(result);
        }
        private static void Main()
        {
            IComparer <Event <uint> >         comparer   = CreateEventComparer();
            IEventStore <uint, Event <uint> > eventStore = new MemoryEventStore <uint, Event <uint> >(comparer);

            for (uint i = 0; i < 10; i++)
            {
                List <Event <uint> > events = new List <Event <uint> >();
                events.Add(new OrderCreatedEvent(i));
                events.Add(new OrderDateChangedEvent(i, DateTime.Now.AddDays(i)));
                events.Add(new OrderDeletedEvent(i));
                eventStore.SaveEvents(i, events);
            }

            IReadOnlyCollection <Event <uint> > found = eventStore.GetEventsById(1);

            Console.WriteLine($"Found events: {found.Count}");
            Console.ReadKey();
        }