mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-12 11:32:10 +08:00
add consumer for pulished message in integration test
This commit is contained in:
parent
6c4ad7094b
commit
66e7236411
15
src/Services/Flight/src/Flight/FlightConsumer.cs
Normal file
15
src/Services/Flight/src/Flight/FlightConsumer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BuildingBlocks.Contracts.EventBus.Messages;
|
||||
using MassTransit;
|
||||
|
||||
namespace Flight;
|
||||
|
||||
public class FlightConsumer : IConsumer<FlightCreated>
|
||||
{
|
||||
public Task Consume(ConsumeContext<FlightCreated> context)
|
||||
{
|
||||
Console.WriteLine("This consumer is for test");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using BuildingBlocks.Contracts.EventBus.Messages;
|
||||
using Flight.Flights.Features.CreateFlight;
|
||||
using FluentAssertions;
|
||||
using Integration.Test.Fakes;
|
||||
@ -32,5 +33,6 @@ public class CreateFlightTest
|
||||
// Assert
|
||||
flightResponse.Should().NotBeNull();
|
||||
flightResponse?.FlightNumber.Should().Be(command.FlightNumber);
|
||||
(await _fixture.IsConsumed<FlightCreated>()).Should().Be(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using BuildingBlocks.Contracts.EventBus.Messages;
|
||||
using BuildingBlocks.Domain.Model;
|
||||
using BuildingBlocks.EFCore;
|
||||
using BuildingBlocks.MassTransit;
|
||||
using BuildingBlocks.Web;
|
||||
using Flight;
|
||||
using Flight.Data;
|
||||
using Flight.Data.Seed;
|
||||
using MassTransit;
|
||||
@ -57,6 +59,8 @@ public class TestFixture : IAsyncLifetime
|
||||
services.ReplaceScoped<IDataSeeder, FlightDataSeeder>();
|
||||
services.AddMassTransitTestHarness(x =>
|
||||
{
|
||||
x.AddConsumer<FlightConsumer>();
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
var rabbitMqOptions = services.GetOptions<RabbitMqOptions>("RabbitMq");
|
||||
@ -70,6 +74,8 @@ public class TestFixture : IAsyncLifetime
|
||||
cfg.ConfigureEndpoints(context);
|
||||
});
|
||||
});
|
||||
|
||||
//FlightConsumer
|
||||
}));
|
||||
|
||||
_harness = _factory.Services.GetTestHarness();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user