public void DispatcherHandlerTest()
        {
            var dispatcher = new Dispatcher();
            var reportingStore = new ReportingStore();

            var assistantManagerDispatcher = new DispatcherHandleOrder(dispatcher, "assistant");

            var cashierDispatcher = new DispatcherHandleOrder(dispatcher, "cashier");

            var cashier = new Cashier(cashierDispatcher, new FakeOrdersStore());

            var cookDispatcher = new DispatcherHandleOrder(dispatcher, "cook");

            var waiterDispatcher = new DispatcherHandleOrder(dispatcher, "waiter");
            var waiter = new Waiter(waiterDispatcher);

            dispatcher.Subscribe("waiter", new QueuedHandleOrders(new Cook(cookDispatcher, new FakeIngredientsStore()), "cook"));
            dispatcher.Subscribe("cook", cashier);
            dispatcher.Subscribe("cashier", new QueuedHandleOrders(new AssistantManager(assistantManagerDispatcher, new FakePriceTable()), "assistant"));
            dispatcher.Subscribe("assistant", new QueuedHandleOrders(new Manger(reportingStore), "manager"));

            waiter.CreateOrder();
            Thread.Sleep(100);
            cashier.PayFor(123);
            Thread.Sleep(1000);

            Assert.That(reportingStore.StoredOrders.Count, Is.EqualTo(1));
        }
 public RestaurantMidget(string correlationId, Dispatcher dispatcher, IScheduler scheduler)
 {
     _correlationId = correlationId;
     _dispatcher = dispatcher;
     _scheduler = scheduler;
 }
 public DispatcherHandleOrder(Dispatcher dispatcher, string name)
 {
     _dispatcher = dispatcher;
     _name = name;
 }
        public void MidgetMonitorTest()
        {
            var dispatcher = new Dispatcher();
            var reportingStore = new ReportingStore();
            var notifyDispatcher = new NotifyDispatcher(dispatcher);

            IScheduler theScheduler = new NeverTimesOut();

            var cashier = new Cashier(notifyDispatcher, new FakeOrdersStore());
            var midgetHouse = new MidgetHouse(dispatcher, theScheduler);
            var waiter = new Waiter(midgetHouse);

            dispatcher.Subscribe("cook", new QueuedHandleOrders(new Cook(notifyDispatcher, new FakeIngredientsStore()), "cook"));
            dispatcher.Subscribe("cashier", cashier);
            dispatcher.Subscribe("assistant", new QueuedHandleOrders(new AssistantManager(notifyDispatcher, new FakePriceTable()), "assistant"));
            dispatcher.Subscribe("manger", new QueuedHandleOrders(new Manger(reportingStore), "manager"));
            dispatcher.SubscribeMidgetInfo("midgetObserver", new MidgetObserver());

            waiter.CreateOrder();
            Thread.Sleep(2000);
            cashier.PayFor(123);
            Thread.Sleep(1000);

            Assert.That(reportingStore.StoredOrders.Count, Is.EqualTo(1));
        }
 public NotifyDispatcher(Dispatcher dispatcher)
 {
     _dispatcher = dispatcher;
 }
        public void ObserverNotifyTest()
        {
            var dispatcher = new Dispatcher();
            var reportingStore = new ReportingStore();

            var assistantManagerDispatcher = new DispatcherHandleOrder(dispatcher, "assistant");
            var cashierDispatcher = new DispatcherHandleOrder(dispatcher, "cashier");
            var cashier = new Cashier(cashierDispatcher, new FakeOrdersStore());
            var cookDispatcher = new DispatcherHandleOrder(dispatcher, "cook");
            var waiterDispatcher = new DispatcherHandleOrder(dispatcher, "waiter");

            var waiter = new Waiter(waiterDispatcher);

            dispatcher.Subscribe("waiter", new QueuedHandleOrders(new Cook(cookDispatcher, new FakeIngredientsStore()), "cook"));
            dispatcher.Subscribe("cook", cashier);
            dispatcher.Subscribe("cashier", new QueuedHandleOrders(new AssistantManager(assistantManagerDispatcher, new FakePriceTable()), "assistant"));
            dispatcher.Subscribe("assistant", new QueuedHandleOrders(new Manger(reportingStore), "manager"));

            dispatcher.SubscribeByCorrelationId("#1", new DelegateObserver((order) => Console.WriteLine("Document changed: {0}", order.TotalTax)));

            waiter.CreateOrder();
            Thread.Sleep(300);
            cashier.PayFor(123);
            Thread.Sleep(2000);

            Assert.That(reportingStore.StoredOrders.Count, Is.EqualTo(1));
        }
 public MidgetHouse(Dispatcher dispatcher, IScheduler scheduler)
 {
     _dispatcher = dispatcher;
     _scheduler = scheduler;
 }