Beispiel #1
0
        public void WhenSavingEvent_ThenCanRetrieveIt()
        {
            var store   = new QueryableStore();
            var product = new Product(id1, "DevStore");

            product.Publish(1);

            store.Persist(product);

            var events = store.Query().Execute().ToList();

            Assert.Equal(2, events.Count);
            Assert.True(events.OfType <Product.CreatedEvent>().Any(x => x.Id == id1 && x.Title == "DevStore"));
            Assert.True(events.OfType <Product.PublishedEvent>().Any(x => x.Version == 1));
        }
Beispiel #2
0
        public void WhenSavingMultipleEvents_ThenCanLoadSpecificObject()
        {
            var store   = new QueryableStore();
            var product = new Product(id1, "DevStore");

            product.Publish(1);

            store.Persist(product);

            product = new Product(id2, "WoVS");
            product.Publish(1);
            product.Publish(2);
            product.Publish(3);

            store.Persist(product);

            var saved = new Product(store.Query().For <Product>(id2).Execute());

            Assert.Equal(3, saved.Version);
            Assert.Equal("WoVS", saved.Title);
            Assert.Equal(id2, saved.Id);
        }
Beispiel #3
0
        public void WhenLoadingFromEventsForSourceTypeAndId_ThenStateIsUpdated()
        {
            var product = new Product(store.Query().For <Product>(id2).Execute());

            Assert.Equal(id2, product.Id);
            Assert.Equal("WoVS", product.Title);
            Assert.Equal(2, product.Version);
        }