change in create new flight test

This commit is contained in:
meysamhadeli 2022-05-19 01:48:37 +04:30
parent 66e7236411
commit 1971267b8e
2 changed files with 3 additions and 12 deletions

View File

@ -18,7 +18,7 @@ public class CreateFlightTest
}
[Fact]
public async Task should_create_new_flight_to_db()
public async Task should_create_new_flight_to_db_and_publish_message_to_broker()
{
// Arrange
var fakeFlight = new FakeCreateFlightCommand().Generate();
@ -33,6 +33,7 @@ public class CreateFlightTest
// Assert
flightResponse.Should().NotBeNull();
flightResponse?.FlightNumber.Should().Be(command.FlightNumber);
(await _fixture.IsConsumed<FlightCreated>()).Should().Be(true);
(await _fixture.IsFaultyPublished<FlightCreated>()).Should().BeFalse();
(await _fixture.IsPublished<FlightCreated>()).Should().BeTrue();
}
}

View File

@ -59,8 +59,6 @@ public class TestFixture : IAsyncLifetime
services.ReplaceScoped<IDataSeeder, FlightDataSeeder>();
services.AddMassTransitTestHarness(x =>
{
x.AddConsumer<FlightConsumer>();
x.UsingRabbitMq((context, cfg) =>
{
var rabbitMqOptions = services.GetOptions<RabbitMqOptions>("RabbitMq");
@ -74,8 +72,6 @@ public class TestFixture : IAsyncLifetime
cfg.ConfigureEndpoints(context);
});
});
//FlightConsumer
}));
_harness = _factory.Services.GetTestHarness();
@ -312,12 +308,6 @@ public class TestFixture : IAsyncLifetime
foreach (var seeder in seeders) await seeder.SeedAllAsync();
}
// private async Task AddInMemoryHarnessAsync()
// {
// _harness = _factory.Services.GetRequiredService<InMemoryTestHarness>();
// await _harness.Start();
// }
private IHttpContextAccessor AddHttpContextAccessorMock(IServiceProvider serviceProvider)
{
var httpContextAccessorMock = Substitute.For<IHttpContextAccessor>();