public async Task Handle_WhenGetInvoiceMessage_ShouldReplyWithInvoice() { // Arrange var invoice = string.Empty; var clientId = "test_client_id"; var equipmentRepository = Substitute.For <IEquipmentRepository>(); var getInvoiceMessage = new GetInvoiceCommand { ClientId = clientId, OrderItems = new List <OrderItem>() }; var handler = new GetInvoiceCommandHandler(equipmentRepository); var context = new TestableMessageHandlerContext(); var expectedInvoiceGeneratedMessage = new InvoiceGeneratedMessage { ClientId = clientId, Invoice = invoice }; // Act await handler.Handle(getInvoiceMessage, context); // Assert context.RepliedMessages.Length.Should().Be(1); context.RepliedMessages[0].Message.Should().BeEquivalentTo(expectedInvoiceGeneratedMessage); }
public async Task <IActionResult> GetInvoiceAsync([FromBody] InvoiceRequestModel invoiceRequestModel) { var getInvoiceCommand = new GetInvoiceCommand { // ClientId or userId should be retrieved from JWT token once authentication is implemented. // But it's out of scope. So here is just stub. ClientId = "test_client_Id", OrderItems = invoiceRequestModel.OrderItems }; await _endpointInstance.Send(getInvoiceCommand).ConfigureAwait(false); return(Accepted()); }