Example #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));
        }
Example #2
0
        public EventSourcingQueryableSpec()
        {
            this.store = new QueryableStore(() => this.utcNow());

            var product = new Product(id1, "DevStore");

            product.Publish(1);
            product.Publish(2);
            product.Publish(3);

            store.Persist(product);

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

            store.Persist(product);
        }
Example #3
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);
        }