fix:unify 'flight' namespace in Booking and Flight modules

This commit is contained in:
a.kafrashian 2025-05-04 12:51:44 +03:30
parent 660cac9ee5
commit c91538493b
7 changed files with 100 additions and 73 deletions

View File

@ -1,6 +1,7 @@
namespace Booking.Booking.Features.CreatingBook.V1;
using Ardalis.GuardClauses;
using BookingFlight;
using BuildingBlocks.Core;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
@ -9,7 +10,6 @@ using BuildingBlocks.EventStoreDB.Repository;
using BuildingBlocks.Web;
using Duende.IdentityServer.EntityFramework.Entities;
using Exceptions;
using Flight;
using FluentValidation;
using Mapster;
using MapsterMapper;
@ -99,7 +99,7 @@ internal class CreateBookingCommandHandler : ICommandHandler<CreateBooking, Crea
Guard.Against.Null(command, nameof(command));
var flight =
await _flightGrpcServiceClient.GetByIdAsync(new Flight.GetByIdRequest { Id = command.FlightId.ToString() }, cancellationToken: cancellationToken);
await _flightGrpcServiceClient.GetByIdAsync(new BookingFlight.GetByIdRequest { Id = command.FlightId.ToString() }, cancellationToken: cancellationToken);
if (flight is null)
{

View File

@ -1,6 +1,6 @@
using Booking.Configuration;
using BookingFlight;
using BuildingBlocks.Web;
using Flight;
using Microsoft.Extensions.DependencyInjection;
using Passenger;

View File

@ -1,6 +1,6 @@
syntax = "proto3";
package flight;
package bookingFlight;
import "google/protobuf/timestamp.proto";
service FlightGrpcService {

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<None Update="xunit.runner.json">

View File

@ -1,43 +1,40 @@
//using System.Threading.Tasks;
//using BuildingBlocks.TestBase;
//using Flight;
//using Flight.Data;
//using FluentAssertions;
//using Integration.Test.Fakes;
//using Xunit;
using BuildingBlocks.TestBase;
using Flight;
using Flight.Data;
using FluentAssertions;
using Integration.Test.Fakes;
using Xunit;
//namespace Integration.Test.Seat.Features;
namespace Integration.Test.Seat.Features;
//using Api;
//using global::Flight.Flights.Features.CreatingFlight.V1;
//using global::Flight.Seats.Features.CreatingSeat.V1;
using Api;
//public class GetAvailableSeatsTests : FlightIntegrationTestBase
//{
// public GetAvailableSeatsTests(
// TestFixture<Program, FlightDbContext, FlightReadDbContext> integrationTestFactory) : base(integrationTestFactory)
// {
// }
public class GetAvailableSeatsTests : FlightIntegrationTestBase
{
public GetAvailableSeatsTests(
TestFixture<Program, FlightDbContext, FlightReadDbContext> integrationTestFactory) : base(integrationTestFactory)
{
}
// [Fact]
// public async Task should_return_available_seats_from_grpc_service()
// {
// // Arrange
// var flightCommand = new FakeCreateFlightMongoCommand().Generate();
[Fact]
public async Task should_return_available_seats_from_grpc_service()
{
// Arrange
var flightCommand = new FakeCreateFlightMongoCommand().Generate();
// await Fixture.SendAsync(flightCommand);
await Fixture.SendAsync(flightCommand);
// var seatCommand = new FakeCreateSeatMongoCommand(flightCommand.Id).Generate();
var seatCommand = new FakeCreateSeatMongoCommand(flightCommand.Id).Generate();
// await Fixture.SendAsync(seatCommand);
await Fixture.SendAsync(seatCommand);
// var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel);
var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel);
// // Act
// var response = await flightGrpcClient.GetAvailableSeatsAsync(new GetAvailableSeatsRequest { FlightId = flightCommand.Id.ToString() });
// Act
var response = await flightGrpcClient.GetAvailableSeatsAsync(new GetAvailableSeatsRequest { FlightId = flightCommand.Id.ToString() });
// // Assert
// response?.Should().NotBeNull();
// response?.SeatDtos?.Count.Should().BeGreaterOrEqualTo(1);
// }
//}
// Assert
response?.Should().NotBeNull();
response?.SeatDtos?.Count.Should().BeGreaterOrEqualTo(1);
}
}

View File

@ -1,43 +1,42 @@
//using System.Threading.Tasks;
//using Api;
//using BuildingBlocks.TestBase;
//using Flight;
//using Flight.Data;
//using FluentAssertions;
//using Integration.Test.Fakes;
//using Xunit;
using Api;
using BuildingBlocks.TestBase;
using Flight;
using Flight.Data;
using FluentAssertions;
using Integration.Test.Fakes;
using Xunit;
//namespace Integration.Test.Seat.Features;
//public class ReserveSeatTests : FlightIntegrationTestBase
//{
// public ReserveSeatTests(
// TestFixture<Program, FlightDbContext, FlightReadDbContext> integrationTestFactory) : base(integrationTestFactory)
// {
// }
namespace Integration.Test.Seat.Features;
public class ReserveSeatTests : FlightIntegrationTestBase
{
public ReserveSeatTests(
TestFixture<Program, FlightDbContext, FlightReadDbContext> integrationTestFactory) : base(integrationTestFactory)
{
}
// [Fact]
// public async Task should_return_valid_reserve_seat_from_grpc_service()
// {
// // Arrange
// var flightCommand = new FakeCreateFlightCommand().Generate();
[Fact]
public async Task should_return_valid_reserve_seat_from_grpc_service()
{
// Arrange
var flightCommand = new FakeCreateFlightCommand().Generate();
// await Fixture.SendAsync(flightCommand);
await Fixture.SendAsync(flightCommand);
// var seatCommand = new FakeCreateSeatCommand(flightCommand.Id).Generate();
var seatCommand = new FakeCreateSeatCommand(flightCommand.Id).Generate();
// await Fixture.SendAsync(seatCommand);
await Fixture.SendAsync(seatCommand);
// var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel);
var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel);
// // Act
// var response = await flightGrpcClient.ReserveSeatAsync(new ReserveSeatRequest()
// {
// FlightId = seatCommand.FlightId.ToString(),
// SeatNumber = seatCommand.SeatNumber
// });
// Act
var response = await flightGrpcClient.ReserveSeatAsync(new ReserveSeatRequest()
{
FlightId = seatCommand.FlightId.ToString(),
SeatNumber = seatCommand.SeatNumber
});
// // Assert
// response?.Should().NotBeNull();
// response?.Id.Should().Be(seatCommand?.Id.ToString());
// }
//}
// Assert
response?.Should().NotBeNull();
response?.Id.Should().Be(seatCommand?.Id.ToString());
}
}

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit.Test", "Unit.Test\Unit.Test.csproj", "{9FF9D3A3-D316-461F-90D8-A51226796AB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "Integration.Test\Integration.Test.csproj", "{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9FF9D3A3-D316-461F-90D8-A51226796AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FF9D3A3-D316-461F-90D8-A51226796AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FF9D3A3-D316-461F-90D8-A51226796AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FF9D3A3-D316-461F-90D8-A51226796AB8}.Release|Any CPU.Build.0 = Release|Any CPU
{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4EB6EA31-EAFC-4770-A32B-52E5EFF62E05}
EndGlobalSection
EndGlobal