
Return new(bookingCreated.BookingId, bookingSummary.FirstName, bookingSummary.LastName,ĭateTime.UtcNow, DateTime.UtcNow, carBooking.PickUpLocation, 100,Įnum.Parse(())) Var bookingSummary = bookingCreated.BookingSummary Var carBooking = bookingCreated.CarBooking Private static MapToCarBooking(BookingCreated bookingCreated) => new(bookingCreated.BookingId, bookingCreated.BookingSummary,īookingCreated.CarBooking, bookingCreated.HotelBooking, bookingCreated.FlightBooking) Private static CarBooked MapToCarBooked(BookingCreated bookingCreated) => await context.Publish(MapToCarBooked(bookingCreated)) Private static async Task PublishCarBookedAsync(ConsumeContext context, BookingCreated bookingCreated) => await _mediator.Send(new MakeCarBookingCommand(MapToCarBooking(bookingCreated))) Private async Task MakeCarBookingAsync(BookingCreated bookingCreated) Public async Task Consume(ConsumeContext context)Īwait MakeCarBookingAsync(bookingCreated) Īwait PublishCarBookedAsync(context, bookingCreated) Public BookingCreatedConsumer(IMediator mediator) Public class BookingCreatedConsumer : IConsumer Note that IMediator is injected using constructor injection: Why are things a little more interesting with MediatR? To answer that, let’s remind ourselves what our BookingCreatedConsumer looks like (see below). MassTransit and MediatR integration testing Send out a CarBooked message using MassTransit so that other downstream services can continue booking other things such as a hotel and flights.Call the CarBookingRepository (which makes an API call to a 3rd party Car Booking API).We’re going to continue with our Car Booking service we’ve been writing which does the below:

Masstransit turnout how to#
Masstransit turnout code#
All the code for this can be found on my GitHub here. In this post, we’ll look at MassTransit and MediatR integration testing.
