Ejemplo n.º 1
0
 public bool Consume(OrderPriced message)
 {
     TopicPubSub.Instance.Publish(Topics.Payment, new OrderReadyForPayment {
         Order = message.Order
     });
     return(true);
 }
Ejemplo n.º 2
0
 public void Handle(OrderPriced m)
 {
     _dispatcher.Publish(new TakePayment(m)
     {
         Order = m.Order
     });
 }
Ejemplo n.º 3
0
 private void HandleInternal(OrderPriced message)
 {
     this.publisher.Publish(new TakePayment(message)
     {
         Order = message.Order
     });
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 public void Handle(OrderPriced message)
 {
     _bus.Publish(new TakePayment(message.Order)
     {
         CorrelationId = message.CorrelationId,
         CausationId   = message.MessageId
     });
 }
Ejemplo n.º 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>());
        }
Ejemplo n.º 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>());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 public void Handle(OrderPriced message)
 {
     if (message == null)
     {
         return;
     }
     _publisher.Publish(new TakePayment()
     {
         CorrelationId = message.CorrelationId,
         CausationId   = message.EventId,
         Order         = message.Order
     });
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
        }
 public void Handle(OrderPriced message)
 {
     _orderStatuses[message.Order.Id] = OrderStatus.Priced;
 }
Ejemplo n.º 14
0
 public void Handle(OrderPriced message)
 {
     Console.WriteLine(message.CorrelationId);
     Console.WriteLine(message.GetType());
     Console.WriteLine(message.Order);
 }