public void Handle(ItemOutOfStock outOfStockNotification, IDocumentSession session)
        {
            var order = session.Load <Order>(outOfStockNotification.OrderId);

            order.Status = "Backordered";
            TestSynch.ProcessedItemOutOfStockEvent.Set();
        }
        public object Handle(OrderPlaced orderPlaced, IDocumentSession session)
        {
            session.Store(new PickList {
                Id = orderPlaced.Id
            });
            var outOfStockEvent = new ItemOutOfStock {
                OrderId = orderPlaced.Id, ItemName = orderPlaced.ItemName
            };

            // wait here for the test to inspect state.
            TestSynch.ProcessedOrderPlacedEvent.Set();
            TestSynch.WarehouseHandlerShouldContinueEvent.WaitOne(5.Seconds());

            return(outOfStockEvent);
        }
예제 #3
0
        public void Handle(ProcessOrder processOrder, IDocumentStore martenStore, IServiceBus bus)
        {
            using (var session = martenStore.OpenSession())
            {
                bus.EnlistInTransaction(session);

                session.Store(new PickList {
                    Id = processOrder.Id
                });
                var outOfStockEvent = new ItemOutOfStock {
                    OrderId = processOrder.Id, ItemName = processOrder.ItemName
                };

                bus.Publish(outOfStockEvent);

                // wait here for the test to inspect state.
                TestSynch.HandledProcessOrderCommand.Set();
                TestSynch.WarehouseHandlerShouldContinueEvent.WaitOne(5.Seconds());

                session.SaveChanges();
            }
        }