public void should_saveEvents()
        {
            var store = CreateEventStore();

            Cart cart = new Cart();
            cart.ChangeUser(new User());
            cart.ChangeUser(new User());

            store.SaveEvents(cart, cart.AppliedEvents);

            var events = store.ListEvents(cart);

            Assert.AreEqual(2, events.Count());
        }
Esempio n. 2
0
        public void cart_change_user()
        {
            Cart cart = new Cart();
            User user = new User();
            cart.ChangeUser(user);

            Assert.AreEqual(cart.AppliedEvents.Count(), 1);
        }
        public void fii ()
        {
            var processor = new MessageProcessor();
            processor.Register<CartUserChanged>(e=> Console.WriteLine(e.CartId + " event handled."));
            
            Cart cart = new Cart();
            cart.ChangeUser(new User());

            processor.Publish(cart.AppliedEvents);
        }
Esempio n. 4
0
        public void add_item ()
        {
            Cart cart = new Cart();

            cart.Add(new CartItem()
            {
                Id = Guid.NewGuid(),
                ProductId = Guid.NewGuid(),
                Quantity = 5
            });
            
            cart.ChangeUser(new User() {Id = Guid.NewGuid()});

            var newCart = new Cart();
            newCart.FillFromHistory(cart.AppliedEvents);

            foreach (var e in newCart.AppliedEvents)
            {
                Console.WriteLine(e.Version + " " + e.GetType().FullName);
            }

            Assert.AreEqual(2, newCart.AppliedEvents.Count());
        }