public void OrderSaga_CartItemAdded_SagaIsCreated()
        {
            var saga = new OrderSaga.Sagas.OrderSaga();

            var busMock = new Mock <IBus>();

            busMock.Setup <ISerializeMessages>(m => m.Serializer).Returns(new JSONSerializer());

            saga.HandleCommandAsync(busMock.Object, new CartItemAdded()
            {
                ProductName = "any product", UserName = "******"
            }, null).Wait();

            Assert.IsTrue(saga.Data != null);
        }
Example #2
0
        public void OrderSaga_ProcessOrder_TwoMessagesAreSent()
        {
            var saga = new OrderSaga.Sagas.OrderSaga();

            var busMock = new Mock <IBus>();

            busMock.Setup <ISerializeMessages>(m => m.Serializer).Returns(new JSONSerializer());

            busMock.Setup <Task>(m => m.SendAsync(It.IsAny <ShipOrder>(), It.IsAny <string>(), null)).Returns(Task.CompletedTask);
            busMock.Setup <Task>(m => m.SendAsync(It.IsAny <PayOrder>(), It.IsAny <string>(), null)).Returns(Task.CompletedTask);

            saga.HandleCommandAsync(busMock.Object, new ProcessOrder()
            {
                UserName = "******"
            }, null).Wait();

            busMock.Verify(foo => foo.SendAsync(It.IsAny <ShipOrder>(), It.IsAny <string>(), null), Times.Once());
            busMock.Verify(foo => foo.SendAsync(It.IsAny <PayOrder>(), It.IsAny <string>(), null), Times.Once());
        }