public void WhenHandlerRegistered_ThenCanProcessEntity() { var id = Guid.NewGuid(); var product = new Product(id, "DevStore"); var context = default(IDomainContext); var eventStream = new EventStream(); IDomainEventStore store = new ConsoleEventStore(); // Keep the handlers so they are not GC'ed. var handlers = new object[] { new ConsoleHandler(eventStream), new SendMailHandler(eventStream), }; context = new DomainContext(eventStream, store); context.Save(product); // Save changes and cause publication of pending events // in the newly created domain object. context.SaveChanges(); Console.WriteLine(); // Here some command might pull the product from the // context, and invoke a domain method. var savedProduct = context.Find<Product>(id); product.Publish(1); // Saving again causes persistence of the entity state // as well as publishing the events. context.SaveChanges(); }
public void WhenHandlerRegistered_ThenCanProcessEntity() { var id = Guid.NewGuid(); var product = new Product(id, "DevStore"); var context = default(IDomainContext); var eventStream = new EventStream(); IDomainEventStore store = new ConsoleEventStore(); // Keep the handlers so they are not GC'ed. var handlers = new object[] { new ConsoleHandler(eventStream), new SendMailHandler(eventStream), }; context = new DomainContext(eventStream, store); context.Save(product); // Save changes and cause publication of pending events // in the newly created domain object. context.SaveChanges(); Console.WriteLine(); // Here some command might pull the product from the // context, and invoke a domain method. var savedProduct = context.Find <Product>(id); product.Publish(1); // Saving again causes persistence of the entity state // as well as publishing the events. context.SaveChanges(); }