Exemplo n.º 1
0
        public void Changing_product_name_should_raise_domain_event()
        {
            const string oldName = "Widget";
            const string newName = "Gadget";

            var product = new Product();

            IDomainEvent @event = null;

            using (DomainEvent.TestWith(e => { @event = e; }))
            {
                product.Name = oldName;
                @event.ShouldBeNull(); // event should not be raised on initial set.

                product.Name = newName;
            }

            var productNameChangedEvent = @event as ProductNameChangedEvent;

            productNameChangedEvent.ShouldNotBeNull();
            productNameChangedEvent.OldProductName.ShouldEqual(oldName);
            productNameChangedEvent.NewProductName.ShouldEqual(newName);
        }