コード例 #1
0
ファイル: Midget.cs プロジェクト: olivierpaes/RestaurantKata
 public bool Consume(OrderPriced message)
 {
     TopicPubSub.Instance.Publish(Topics.Payment, new OrderReadyForPayment {
         Order = message.Order
     });
     return(true);
 }
コード例 #2
0
ファイル: PayFirstRunner.cs プロジェクト: jen20/restaurant
 public void Handle(OrderPriced m)
 {
     _dispatcher.Publish(new TakePayment(m)
     {
         Order = m.Order
     });
 }
コード例 #3
0
 private void HandleInternal(OrderPriced message)
 {
     this.publisher.Publish(new TakePayment(message)
     {
         Order = message.Order
     });
 }
コード例 #4
0
        public void after_orderPriced_then_takePayment()
        {
            // given
            var d = new FakeDispatcher();
            var m = new Runner(d);
            var o = new Order {
                OrderId = Guid.NewGuid()
            };

            // when
            var inputEvent = new OrderPriced {
                Order = o
            };

            m.Handle(inputEvent);

            // then
            Assert.Single(d.Messages);

            Assert.IsType <TakePayment>(d.Messages[0]);

            var x0 = d.Messages[0] as TakePayment;

            Assert.Equal(o.OrderId, x0.Order.OrderId);
            Assert.Equal(inputEvent.CorrelationId, x0.CorrelationId);
            Assert.Equal(inputEvent.MessageId, x0.ParentId);
        }
コード例 #5
0
 public void Handle(OrderPriced message)
 {
     _bus.Publish(new TakePayment(message.Order)
     {
         CorrelationId = message.CorrelationId,
         CausationId   = message.MessageId
     });
 }
コード例 #6
0
        public void WhenMidgetNotifiedOfOrderPriced_ThenMidgetSendsCommandToTakePayment()
        {
            var orderPriced = new OrderPriced(order, Guid.NewGuid(), orderGuid);

            var midget = new EnglishMidget(bus, orderGuid);
            midget.Handle(orderPriced);

            Assert.That(bus.Messages.Single(), Is.InstanceOf<TakePayment>());
        }
コード例 #7
0
        public void WhenMidgetNotifiedOfOrderPriced_ThenMidgetSendsCommandToTakePayment()
        {
            var orderPriced = new OrderPriced(order, Guid.NewGuid(), orderGuid);

            var midget = new EnglishMidget(bus, orderGuid);

            midget.Handle(orderPriced);

            Assert.That(bus.Messages.Single(), Is.InstanceOf <TakePayment>());
        }
コード例 #8
0
        public void Handle(OrderPriced order)
        {
            var message = new TakePayment {
                Order = order.Order
            };

            message.ReplyTo(order);

            _publisher.Publish(message);
        }
        public void Handle(OrderPriced message)
        {
            var payForOrder = new PayForOrder(message.Order)
            {
                MessageId     = Guid.NewGuid(),
                CorrelationId = message.CorrelationId,
                CausationId   = message.MessageId
            };

            _bus.Publish(payForOrder);
        }
コード例 #10
0
 public void Handle(OrderPriced message)
 {
     if (message == null)
     {
         return;
     }
     _publisher.Publish(new TakePayment()
     {
         CorrelationId = message.CorrelationId,
         CausationId   = message.EventId,
         Order         = message.Order
     });
 }
コード例 #11
0
 public void Handle(OrderPriced message)
 {
     if (_expectedNextCausationId == message.CausationId)
     {
         var payForOrder = new PayForOrder(message.Order)
         {
             MessageId     = Guid.NewGuid(),
             CorrelationId = message.CorrelationId,
             CausationId   = message.MessageId
         };
         _expectedNextCausationId = payForOrder.MessageId;
         _bus.Publish(payForOrder);
     }
     else
     {
         Console.WriteLine("Received Evil Message: Order Priced {0}", message.Order.Id);
     }
 }
コード例 #12
0
        public void Handle(PriceOrder message)
        {
            var order = message.Order;

            Console.WriteLine("Pricing...");

            order.LineItems.ForEach(item => order = order.SetLinePrice(item.Id, 5.10m));
            var subTotal = order.LineItems.Sum(x => x.Price);
            var tax      = subTotal * 0.1m;

            order = order.SetTax(tax)
                    .SetTotal(tax + subTotal);


            var @event = new OrderPriced {
                Order = order
            };

            @event.CorrelationId = message.CorrelationId;
            @event.CausationId   = message.Id;

            _bus.Publish(@event);
        }
コード例 #13
0
 public void Handle(OrderPriced message)
 {
     _orderStatuses[message.Order.Id] = OrderStatus.Priced;
 }
コード例 #14
0
 public void Handle(OrderPriced message)
 {
     Console.WriteLine(message.CorrelationId);
     Console.WriteLine(message.GetType());
     Console.WriteLine(message.Order);
 }