Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<SpaRoot>..\jmayer.example.aspreact.client</SpaRoot>
<SpaProxyLaunchCommand>npm run dev</SpaProxyLaunchCommand>
<SpaProxyServerUrl>https://localhost:5173</SpaProxyServerUrl>
<Version>9.0.1</Version>
<Version>9.1.0</Version>
<Authors>jmayer913</Authors>
<Company>jmayer913</Company>
<RepositoryUrl>https://github.com/jmayer913/JMayer-Example-ASPReact</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JMayer.Web.Mvc" Version="9.0.2" />
<PackageReference Include="JMayer.Web.Mvc" Version="9.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
<Version>9.0.12</Version>
<Version>9.0.15</Version>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
</ItemGroup>

<ItemGroup>
Expand Down
84 changes: 42 additions & 42 deletions TestProject/Airlines/AirlineWebRequestUnitTest.cs

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions TestProject/Flights/FlightWebRequestUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public class FlightWebRequestUnitTest : IClassFixture<WebApplicationFactory<Prog
IATA = iata,
Name = iata,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

return operationResult.DataObject as Airline;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task VerifyAddDuplicateFlightFailure()
Name = "Add Duplicate Flight Test 1",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);
Assert.True(operationResult.IsSuccessStatusCode, "Failed to create the first flight.");

operationResult = await dataLayer.CreateAsync(new Flight()
Expand All @@ -283,7 +283,7 @@ public async Task VerifyAddDuplicateFlightFailure()
Name = "Add Duplicate Flight Test New",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -353,7 +353,7 @@ public async Task VerifyAddFlight(string gateName, string airlineIATA, string fl
Destination = destination,
SortDestinationID = sortDestination.Integer64ID,
};
OperationResult operationResult = await dataLayer.CreateAsync(flight);
OperationResult operationResult = await dataLayer.CreateAsync(flight, TestContext.Current.CancellationToken);

Assert.True(operationResult.IsSuccessStatusCode, "The operation should have been successful."); //The operation must have been successful.
Assert.IsType<Flight>(operationResult.DataObject); //A flight must have been returned.
Expand All @@ -379,7 +379,7 @@ public async Task VerifyAddFlightAirlineNotFoundFailure()
Name = "Add Flight Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -415,7 +415,7 @@ public async Task VerifyAddFlightBadDestinationFailure()
Name = "Add Bad Destination Test",
Destination = BadFormatttedDestination,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -451,7 +451,7 @@ public async Task VerifyAddFlightBadFlightNumberFailure()
Name = "Add Bad Flight Number Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -488,7 +488,7 @@ public async Task VerifyAddFlightCodeShareAirlineNotFoundFailure()
Name = "Add Flight CodeShare Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -524,7 +524,7 @@ public async Task VerifyAddFlightGateNotFoundFailure()
Name = "Add Flight Gate Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -560,7 +560,7 @@ public async Task VerifyAddFlightSortDestinationNotFoundFailure()
Name = "Add Flight Sort Destination Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = BadSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand All @@ -587,7 +587,7 @@ public async Task VerifyCountFlights()
HttpClient httpClient = _factory.CreateClient();
FlightDataLayer dataLayer = new(httpClient);

long count = await dataLayer.CountAsync();
long count = await dataLayer.CountAsync(TestContext.Current.CancellationToken);
Assert.True(count > 0);
}

Expand Down Expand Up @@ -617,13 +617,13 @@ public async Task VerifyDeleteAirlineCascade()
Name = "Delete Airline Cascade Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);
Assert.True(operationResult.IsSuccessStatusCode, "Failed to create the flight.");

operationResult = await new Airlines.AirlineDataLayer(httpClient).DeleteAsync(airline);
operationResult = await new Airlines.AirlineDataLayer(httpClient).DeleteAsync(airline, TestContext.Current.CancellationToken);
Assert.True(operationResult.IsSuccessStatusCode, "Failed to delete the airline.");

List<Flight>? flights = await dataLayer.GetAllAsync();
List<Flight>? flights = await dataLayer.GetAllAsync(TestContext.Current.CancellationToken);

if (flights is null)
{
Expand Down Expand Up @@ -653,11 +653,11 @@ public async Task VerifyDeleteFlight()
Name = "Delete Flight Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight flight)
{
operationResult = await dataLayer.DeleteAsync(flight);
operationResult = await dataLayer.DeleteAsync(flight, TestContext.Current.CancellationToken);
Assert.True(operationResult.IsSuccessStatusCode);
}
else
Expand All @@ -675,7 +675,7 @@ public async Task VerifyGetAllFlights()
{
HttpClient httpClient = _factory.CreateClient();
FlightDataLayer dataLayer = new(httpClient);
List<Flight>? flights = await dataLayer.GetAllAsync();
List<Flight>? flights = await dataLayer.GetAllAsync(TestContext.Current.CancellationToken);

//Flights must have been returned.
Assert.NotNull(flights);
Expand All @@ -691,7 +691,7 @@ public async Task VerifyGetAllListViewFlights()
{
HttpClient httpClient = _factory.CreateClient();
FlightDataLayer dataLayer = new(httpClient);
List<ListView>? flights = await dataLayer.GetAllListViewAsync();
List<ListView>? flights = await dataLayer.GetAllListViewAsync(TestContext.Current.CancellationToken);

//List view flights must have been returned.
Assert.NotNull(flights);
Expand All @@ -708,7 +708,7 @@ public async Task VerifyGetSingleFlight()
HttpClient httpClient = _factory.CreateClient();
FlightDataLayer dataLayer = new(httpClient);

Flight? flight = await dataLayer.GetSingleAsync();
Flight? flight = await dataLayer.GetSingleAsync(TestContext.Current.CancellationToken);
Assert.NotNull(flight);
}

Expand All @@ -722,7 +722,7 @@ public async Task VerifyGetSingleFlightWithId()
HttpClient httpClient = _factory.CreateClient();
FlightDataLayer dataLayer = new(httpClient);

Flight? flight = await dataLayer.GetSingleAsync(1);
Flight? flight = await dataLayer.GetSingleAsync(1, TestContext.Current.CancellationToken);
Assert.NotNull(flight);
}

Expand All @@ -745,7 +745,7 @@ public async Task VerifyUpdateDuplicateFlightFailure()
Name = "Update Duplicate Flight Test 1",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);
Assert.True(operationResult.IsSuccessStatusCode, "Failed to create the first flight.");

operationResult = await dataLayer.CreateAsync(new Flight()
Expand All @@ -757,7 +757,7 @@ public async Task VerifyUpdateDuplicateFlightFailure()
Name = "Update Duplicate Flight Test New",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight secondFlight)
{
Expand All @@ -771,7 +771,7 @@ public async Task VerifyUpdateDuplicateFlightFailure()
Name = "Update Duplicate Flight Test New",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -842,7 +842,7 @@ public async Task VerifyUpdateFlight(string gateName, string airlineIATA, string
Name = $"{airline.IATA}{flightNumber}",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight createdFlight)
{
Expand All @@ -860,7 +860,7 @@ public async Task VerifyUpdateFlight(string gateName, string airlineIATA, string
Destination = destination,
SortDestinationID = sortDestination.Integer64ID,
};
operationResult = await dataLayer.UpdateAsync(flight);
operationResult = await dataLayer.UpdateAsync(flight, TestContext.Current.CancellationToken);

Assert.True(operationResult.IsSuccessStatusCode, "The operation should have been successful."); //The operation must have been successful.
Assert.IsType<Flight>(operationResult.DataObject); //A flight must have been returned.
Expand Down Expand Up @@ -891,7 +891,7 @@ public async Task VerifyUpdateFlightAirlineNotFoundFailure()
Name = "Update Flight Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight createdFlight)
{
Expand All @@ -905,7 +905,7 @@ public async Task VerifyUpdateFlightAirlineNotFoundFailure()
Name = "Update Flight Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -946,12 +946,12 @@ public async Task VerifyUpdateFlightBadDestinationFailure()
Name = "Update Bad Destination Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight flight)
{
flight.Destination = BadFormatttedDestination;
operationResult = await dataLayer.UpdateAsync(flight);
operationResult = await dataLayer.UpdateAsync(flight, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -992,12 +992,12 @@ public async Task VerifyUpdateFlightBadFlightNumberFailure()
Name = "Update Bad Flight Number Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight flight)
{
flight.FlightNumber = BadFormatttedFlightNumber;
operationResult = await dataLayer.UpdateAsync(flight);
operationResult = await dataLayer.UpdateAsync(flight, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -1038,7 +1038,7 @@ public async Task VerifyUpdateFlightCodeShareAirlineNotFoundFailure()
Name = "Update Flight CodeShare Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight createdFlight)
{
Expand All @@ -1053,7 +1053,7 @@ public async Task VerifyUpdateFlightCodeShareAirlineNotFoundFailure()
Name = "Update Flight CodeShare Airline Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -1094,7 +1094,7 @@ public async Task VerifyUpdateFlightGateNotFoundFailure()
Name = "Update Flight Gate Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight createdFlight)
{
Expand All @@ -1108,7 +1108,7 @@ public async Task VerifyUpdateFlightGateNotFoundFailure()
Name = "Update Flight Gate Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down Expand Up @@ -1149,7 +1149,7 @@ public async Task VerifyUpdateFlightSortDestinationNotFoundFailure()
Name = "Update Flight Sort Destination Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = DefaultSortDestinationID,
});
}, TestContext.Current.CancellationToken);

if (operationResult.IsSuccessStatusCode && operationResult.DataObject is Flight createdFlight)
{
Expand All @@ -1163,7 +1163,7 @@ public async Task VerifyUpdateFlightSortDestinationNotFoundFailure()
Name = "Update Flight Sort Destination Not Found Test",
Destination = DefaultAirportCode,
SortDestinationID = BadSortDestinationID,
});
}, TestContext.Current.CancellationToken);

//The operation must have failed.
Assert.False(operationResult.IsSuccessStatusCode, "The operation should have failed.");
Expand Down
Loading
Loading