Use wrapper class for get all api endpoints
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
To enable e.g. pagination in the future
This commit is contained in:
@@ -23,12 +23,12 @@ public class GetCarsTests : IAsyncLifetime
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
var response = await _factory.HttpClient.GetAsync("v1/cars");
|
||||
using HttpResponseMessage response = await _factory.HttpClient.GetAsync("v1/cars");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var cars = await response.Content.ReadFromJsonAsync<IEnumerable<GetCars.Response>>();
|
||||
cars.Should().BeEmpty();
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<GetCars.ApiResponse>();
|
||||
apiResponse!.Cars.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -40,8 +40,8 @@ public class GetCarsTests : IAsyncLifetime
|
||||
const int numberOfCars = 5;
|
||||
for (var i = 0; i < numberOfCars; i++)
|
||||
{
|
||||
var createCarRequest = _carFaker.CreateCarRequest();
|
||||
var createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest);
|
||||
CreateCar.Request createCarRequest = _carFaker.CreateCarRequest();
|
||||
HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest);
|
||||
createCarResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var createdCar = await createCarResponse.Content.ReadFromJsonAsync<CreateCar.Response>();
|
||||
@@ -49,12 +49,12 @@ public class GetCarsTests : IAsyncLifetime
|
||||
}
|
||||
|
||||
// Act
|
||||
var response = await _factory.HttpClient.GetAsync("v1/cars");
|
||||
using HttpResponseMessage response = await _factory.HttpClient.GetAsync("v1/cars");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var cars = await response.Content.ReadFromJsonAsync<IEnumerable<GetCars.Response>>();
|
||||
cars.Should().BeEquivalentTo(createdCars);
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<GetCars.ApiResponse>();
|
||||
apiResponse!.Cars.Should().BeEquivalentTo(createdCars);
|
||||
}
|
||||
|
||||
public Task InitializeAsync() => Task.CompletedTask;
|
||||
|
||||
@@ -42,8 +42,8 @@ public class GetConsumptionsTests : IAsyncLifetime
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var consumptions = await response.Content.ReadFromJsonAsync<List<GetConsumptions.Response>>();
|
||||
consumptions.Should().BeEquivalentTo(createdConsumptions);
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<GetConsumptions.ApiResponse>();
|
||||
apiResponse!.Consumptions.Should().BeEquivalentTo(createdConsumptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -56,8 +56,8 @@ public class GetConsumptionsTests : IAsyncLifetime
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var consumptions = await response.Content.ReadFromJsonAsync<List<GetConsumptions.Response>>();
|
||||
consumptions.Should().BeEmpty();
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<GetConsumptions.ApiResponse>();
|
||||
apiResponse!.Consumptions.Should().BeEmpty();
|
||||
}
|
||||
|
||||
private async Task<CreateConsumption.Response> CreateConsumptionAsync()
|
||||
|
||||
Reference in New Issue
Block a user