public void Canceling_a_shipping() { Delivery delivery = CreateDelivery(); var messageBusMock = new Mock <IMessageBusGateway>(); var controller = new DeliveryController(null, messageBusMock.Object); Envelope envelope = controller.CancelShipping(delivery.Id); envelope.IsError.Should().BeFalse(); // Check the delivery state in the db messageBusMock.Verify(x => x.SendMessage("Type: ShippingIsCancelled;" + $"Id: {delivery.Id};" + $"Latitude: {delivery.Coordinates.Latitude};" + $"Longitude: {delivery.Coordinates.Longitude}")); }
public void Canceling_a_shipping_with_spy() { Delivery delivery = CreateDelivery(); var messageBusSpy = new MessageBusGatewaySpy(); var controller = new DeliveryController(null, messageBusSpy); Envelope envelope = controller.CancelShipping(delivery.Id); envelope.IsError.Should().BeFalse(); // Check the delivery state in the db messageBusSpy.ShouldSendNumberOfMessages(1) .WithShippingIsCancelledMessage( delivery.Id, delivery.Coordinates.Latitude, delivery.Coordinates.Longitude); }