public void LoadEventsTest()
        {
            var aggregateRootId = Guid.NewGuid();
            var employee        = new Employee(aggregateRootId);

            var event1 = new NameChangedEvent("daxnet");
            var event2 = new TitleChangedEvent("title");
            var event3 = new RegisteredEvent();

            event1.AttachTo(employee);
            event2.AttachTo(employee);
            event3.AttachTo(employee);

            var storeConfig       = new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator());
            var payloadSerializer = new ObjectJsonSerializer();
            var store             = new PostgreSqlEventStore(storeConfig, payloadSerializer);

            store.Save(new List <DomainEvent>
            {
                event1,
                event2,
                event3
            });

            var events = store.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId);

            Assert.Equal(3, events.Count());
        }
        public void EventSequenceAfterSaveTest()
        {
            using (var eventPublisher = new EventBus(connectionFactory, messageSerializer, this.GetType().Name))
                using (var eventStore = new PostgreSqlEventStore(new AdoNetEventStoreConfiguration(PostgreSQLFixture.ConnectionString, new GuidKeyGenerator()), eventStoreSerializer))
                    using (var repository = new EventSourcingDomainRepository(eventStore, eventPublisher, snapshotProvider))
                    {
                        var aggregateRootId = Guid.NewGuid();
                        var employee        = new Employee(aggregateRootId);
                        employee.ChangeName("daxnet");
                        employee.ChangeTitle("developer");
                        repository.Save <Guid, Employee>(employee);

                        var events = eventStore.Load <Guid>(typeof(Employee).AssemblyQualifiedName, aggregateRootId).ToList();
                        Assert.Equal(3, events.Count);
                        Assert.Equal(1, (events[0] as IDomainEvent).Sequence);
                        Assert.Equal(2, (events[1] as IDomainEvent).Sequence);
                        Assert.Equal(3, (events[2] as IDomainEvent).Sequence);
                    }
        }