refactor unit test

This commit is contained in:
meysamhadeli 2022-06-11 00:09:50 +04:30
parent a7a1f1a81d
commit ed931ae0f2
6 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@ namespace Flight.Aircrafts.Dtos;
public record AircraftResponseDto
{
public long Id { get; set; }
public string Name { get; init; }
public string Model { get; init; }
public int ManufacturingYear { get; init; }

View File

@ -1,6 +1,7 @@
namespace Flight.Airports.Dtos;
public record AirportResponseDto
{
public long Id { get; set; }
public string Name { get; init; }
public string Address { get; init; }
public string Code { get; init; }

View File

@ -36,10 +36,10 @@ public class CreateAircraftCommandHandlerTests
var response = await Act(command, CancellationToken.None);
// Assert
var entity = await _fixture.DbContext.Aircraft.SingleOrDefaultAsync(x => x.Model == response.Model);
var entity = await _fixture.DbContext.Aircraft.FindAsync(response?.Id);
entity?.Should().NotBeNull();
response?.Model.Should().Be(entity?.Model);
response?.Id.Should().Be(entity?.Id);
}
[Fact]

View File

@ -37,10 +37,10 @@ public class CreateAirportCommandHandlerTests
var response = await Act(command, CancellationToken.None);
// Assert
var entity = await _fixture.DbContext.Airports.SingleOrDefaultAsync(x => x.Code == response.Code);
var entity = await _fixture.DbContext.Airports.FindAsync(response?.Id);
entity?.Should().NotBeNull();
response?.Code.Should().Be(entity?.Code);
response?.Id.Should().Be(entity?.Id);
}
[Fact]

View File

@ -39,6 +39,7 @@ public class CreateFlightCommandHandlerTests
entity?.Should().NotBeNull();
response?.Id.Should().Be(entity?.Id);
response?.FlightNumber.Should().Be(entity?.FlightNumber);
}
[Fact]

View File

@ -39,7 +39,7 @@ public class CreateSeatCommandHandlerTests
var response = await Act(command, CancellationToken.None);
// Assert
var entity = await _fixture.DbContext.Seats.SingleOrDefaultAsync(x => x.SeatNumber == response.SeatNumber);
var entity = await _fixture.DbContext.Seats.FindAsync(response?.Id);
entity?.Should().NotBeNull();
response?.Id.Should().Be(entity?.Id);