diff --git a/src/Vegasco.Server.Api/Cars/CreateCar.cs b/src/Vegasco.Server.Api/Cars/CreateCar.cs index d87efe5..8f7ef96 100644 --- a/src/Vegasco.Server.Api/Cars/CreateCar.cs +++ b/src/Vegasco.Server.Api/Cars/CreateCar.cs @@ -65,7 +65,7 @@ public static class CreateCar UserId = userId }; - var isDuplicate = await dbContext.Cars + bool isDuplicate = await dbContext.Cars .AnyAsync(x => x.Name.ToUpper() == request.Name.ToUpper(), cancellationToken); if (isDuplicate) diff --git a/src/Vegasco.Server.Api/Cars/DeleteCar.cs b/src/Vegasco.Server.Api/Cars/DeleteCar.cs index a6d0aab..853c665 100644 --- a/src/Vegasco.Server.Api/Cars/DeleteCar.cs +++ b/src/Vegasco.Server.Api/Cars/DeleteCar.cs @@ -21,7 +21,7 @@ public static class DeleteCar ILoggerFactory loggerFactory, CancellationToken cancellationToken) { - var rows = await dbContext.Cars + int rows = await dbContext.Cars .Where(x => x.Id == new CarId(id)) .ExecuteDeleteAsync(cancellationToken); @@ -32,7 +32,7 @@ public static class DeleteCar if (rows > 1) { - var logger = loggerFactory.CreateLogger(nameof(DeleteCar)); + ILogger logger = loggerFactory.CreateLogger(nameof(DeleteCar)); logger.LogWarning("Deleted '{DeletedRowCount}' rows for id '{CarId}'", rows, id); } diff --git a/src/Vegasco.Server.Api/Cars/GetCar.cs b/src/Vegasco.Server.Api/Cars/GetCar.cs index c4b401c..b9fc687 100644 --- a/src/Vegasco.Server.Api/Cars/GetCar.cs +++ b/src/Vegasco.Server.Api/Cars/GetCar.cs @@ -29,7 +29,7 @@ public static class GetCar return TypedResults.NotFound(); } - var response = new Response(car.Id.Value, car.Name); + Response response = new Response(car.Id.Value, car.Name); return TypedResults.Ok(response); } } \ No newline at end of file diff --git a/src/Vegasco.Server.Api/Cars/GetCars.cs b/src/Vegasco.Server.Api/Cars/GetCars.cs index 9f9f096..5a1ed2a 100644 --- a/src/Vegasco.Server.Api/Cars/GetCars.cs +++ b/src/Vegasco.Server.Api/Cars/GetCars.cs @@ -38,7 +38,7 @@ public static class GetCars .Select(x => new ResponseDto(x.Id.Value, x.Name)) .ToListAsync(cancellationToken); - var response = new ApiResponse + ApiResponse response = new ApiResponse { Cars = cars }; diff --git a/src/Vegasco.Server.Api/Cars/UpdateCar.cs b/src/Vegasco.Server.Api/Cars/UpdateCar.cs index 055f509..ff97f20 100644 --- a/src/Vegasco.Server.Api/Cars/UpdateCar.cs +++ b/src/Vegasco.Server.Api/Cars/UpdateCar.cs @@ -55,7 +55,7 @@ public static class UpdateCar return TypedResults.NotFound(); } - var isDuplicate = await dbContext.Cars + bool isDuplicate = await dbContext.Cars .AnyAsync(x => x.Name.ToUpper() == request.Name.ToUpper(), cancellationToken); if (isDuplicate) diff --git a/src/Vegasco.Server.Api/Common/DependencyInjectionExtensions.cs b/src/Vegasco.Server.Api/Common/DependencyInjectionExtensions.cs index 44faa51..ccdbd30 100644 --- a/src/Vegasco.Server.Api/Common/DependencyInjectionExtensions.cs +++ b/src/Vegasco.Server.Api/Common/DependencyInjectionExtensions.cs @@ -121,7 +121,7 @@ public static class DependencyInjectionExtensions .ValidateFluently() .ValidateOnStart(); - var jwtOptions = services.BuildServiceProvider().GetRequiredService>(); + IOptions jwtOptions = services.BuildServiceProvider().GetRequiredService>(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, o => diff --git a/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs b/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs index 774741b..48dae75 100644 --- a/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs +++ b/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs @@ -21,7 +21,7 @@ public static class DeleteConsumption ILoggerFactory loggerFactory, CancellationToken cancellationToken) { - var rows = await dbContext.Consumptions + int rows = await dbContext.Consumptions .Where(x => x.Id == new ConsumptionId(id)) .ExecuteDeleteAsync(cancellationToken); @@ -32,7 +32,7 @@ public static class DeleteConsumption if (rows > 1) { - var logger = loggerFactory.CreateLogger(nameof(DeleteConsumption)); + ILogger logger = loggerFactory.CreateLogger(nameof(DeleteConsumption)); logger.LogWarning("Deleted '{DeletedRowCount}' rows for id '{ConsumptionId}'", rows, id); } diff --git a/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs b/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs index 84d63a6..b440142 100644 --- a/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs +++ b/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs @@ -59,7 +59,7 @@ public static class GetConsumptions List responses = []; - foreach (var consumptions in consumptionsByCar.Select(x => x.Value)) + foreach (List consumptions in consumptionsByCar.Select(x => x.Value)) { for (int i = 0; i < consumptions.Count; i++) { diff --git a/src/Vegasco.Server.Api/Persistence/ApplyMigrationsService.cs b/src/Vegasco.Server.Api/Persistence/ApplyMigrationsService.cs index 3b0ffc7..6fd5afb 100644 --- a/src/Vegasco.Server.Api/Persistence/ApplyMigrationsService.cs +++ b/src/Vegasco.Server.Api/Persistence/ApplyMigrationsService.cs @@ -11,12 +11,12 @@ public class ApplyMigrationsService( { public async Task StartAsync(CancellationToken cancellationToken) { - using var activity = activitySource.StartActivity("ApplyMigrations"); + using Activity? activity = activitySource.StartActivity("ApplyMigrations"); logger.LogInformation("Starting migrations"); using IServiceScope scope = scopeFactory.CreateScope(); - await using var dbContext = scope.ServiceProvider.GetRequiredService(); + await using ApplicationDbContext dbContext = scope.ServiceProvider.GetRequiredService(); await dbContext.Database.MigrateAsync(cancellationToken); } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Cars/CreateCarTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Cars/CreateCarTests.cs index 28d3dd5..95c076c 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Cars/CreateCarTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Cars/CreateCarTests.cs @@ -35,7 +35,7 @@ public class CreateCarTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.Created); - var createdCar = await response.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await response.Content.ReadFromJsonAsync(); createdCar.Should().BeEquivalentTo(createCarRequest, o => o.ExcludingMissingMembers()); _dbContext.Cars.Should().ContainEquivalentOf(createdCar, o => o.Excluding(x => x!.Id)) @@ -46,14 +46,14 @@ public class CreateCarTests : IAsyncLifetime public async Task CreateCar_ShouldReturnValidationProblems_WhenRequestIsNotValid() { // Arrange - var createCarRequest = new CreateCar.Request(""); + CreateCar.Request createCarRequest = new CreateCar.Request(""); // Act HttpResponseMessage response = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); - var validationProblemDetails = await response.Content.ReadFromJsonAsync(); + ValidationProblemDetails? validationProblemDetails = await response.Content.ReadFromJsonAsync(); validationProblemDetails!.Errors.Keys.Should().Contain(x => x.Equals(nameof(CreateCar.Request.Name), StringComparison.OrdinalIgnoreCase)); diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Cars/DeleteCarTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Cars/DeleteCarTests.cs index ba76a29..3348ded 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Cars/DeleteCarTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Cars/DeleteCarTests.cs @@ -27,7 +27,7 @@ public class DeleteCarTests : IAsyncLifetime public async Task DeleteCar_ShouldReturnNotFound_WhenCarDoesNotExist() { // Arrange - var randomCarId = Guid.NewGuid(); + Guid randomCarId = Guid.NewGuid(); // Act HttpResponseMessage response = await _factory.HttpClient.DeleteAsync($"v1/cars/{randomCarId}"); @@ -43,7 +43,7 @@ public class DeleteCarTests : IAsyncLifetime CreateCar.Request createCarRequest = _carFaker.CreateCarRequest(); HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCar = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await createCarResponse.Content.ReadFromJsonAsync(); // Act HttpResponseMessage response = await _factory.HttpClient.DeleteAsync($"v1/cars/{createdCar!.Id}"); diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarTests.cs index 81ddb53..8a69239 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarTests.cs @@ -21,7 +21,7 @@ public class GetCarTests : IAsyncLifetime public async Task GetCar_ShouldReturnNotFound_WhenCarDoesNotExist() { // Arrange - var randomCarId = Guid.NewGuid(); + Guid randomCarId = Guid.NewGuid(); // Act HttpResponseMessage response = await _factory.HttpClient.GetAsync($"v1/cars/{randomCarId}"); @@ -37,14 +37,14 @@ public class GetCarTests : IAsyncLifetime CreateCar.Request createCarRequest = _carFaker.CreateCarRequest(); HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCar = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await createCarResponse.Content.ReadFromJsonAsync(); // Act HttpResponseMessage response = await _factory.HttpClient.GetAsync($"v1/cars/{createdCar!.Id}"); // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); - var car = await response.Content.ReadFromJsonAsync(); + GetCar.Response? car = await response.Content.ReadFromJsonAsync(); car.Should().BeEquivalentTo(createdCar); } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarsTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarsTests.cs index 17a45dd..6ac7d57 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarsTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Cars/GetCarsTests.cs @@ -27,7 +27,7 @@ public class GetCarsTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); - var apiResponse = await response.Content.ReadFromJsonAsync(); + GetCars.ApiResponse? apiResponse = await response.Content.ReadFromJsonAsync(); apiResponse!.Cars.Should().BeEmpty(); } @@ -38,13 +38,13 @@ public class GetCarsTests : IAsyncLifetime List createdCars = []; const int numberOfCars = 5; - for (var i = 0; i < numberOfCars; i++) + for (int i = 0; i < numberOfCars; i++) { CreateCar.Request createCarRequest = _carFaker.CreateCarRequest(); HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCar = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await createCarResponse.Content.ReadFromJsonAsync(); createdCars.Add(createdCar!); } @@ -53,7 +53,7 @@ public class GetCarsTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); - var apiResponse = await response.Content.ReadFromJsonAsync(); + GetCars.ApiResponse? apiResponse = await response.Content.ReadFromJsonAsync(); apiResponse!.Cars.Should().BeEquivalentTo(createdCars); } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Cars/UpdateCarTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Cars/UpdateCarTests.cs index 3896669..f97ca4b 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Cars/UpdateCarTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Cars/UpdateCarTests.cs @@ -31,7 +31,7 @@ public class UpdateCarTests : IAsyncLifetime CreateCar.Request createCarRequest = _carFaker.CreateCarRequest(); HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCar = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await createCarResponse.Content.ReadFromJsonAsync(); UpdateCar.Request updateCarRequest = _carFaker.UpdateCarRequest(); @@ -40,7 +40,7 @@ public class UpdateCarTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); - var updatedCar = await response.Content.ReadFromJsonAsync(); + CreateCar.Response? updatedCar = await response.Content.ReadFromJsonAsync(); updatedCar!.Id.Should().Be(createdCar.Id); updatedCar.Should().BeEquivalentTo(updateCarRequest, o => o.ExcludingMissingMembers()); @@ -57,16 +57,16 @@ public class UpdateCarTests : IAsyncLifetime CreateCar.Request createCarRequest = _carFaker.CreateCarRequest(); HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCar = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCar = await createCarResponse.Content.ReadFromJsonAsync(); - var updateCarRequest = new UpdateCar.Request(""); + UpdateCar.Request updateCarRequest = new UpdateCar.Request(""); // Act HttpResponseMessage response = await _factory.HttpClient.PutAsJsonAsync($"v1/cars/{createdCar!.Id}", updateCarRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); - var validationProblemDetails = await response.Content.ReadFromJsonAsync(); + ValidationProblemDetails? validationProblemDetails = await response.Content.ReadFromJsonAsync(); validationProblemDetails!.Errors.Keys.Should().Contain(x => x.Equals(nameof(CreateCar.Request.Name), StringComparison.OrdinalIgnoreCase)); @@ -80,7 +80,7 @@ public class UpdateCarTests : IAsyncLifetime { // Arrange UpdateCar.Request updateCarRequest = _carFaker.UpdateCarRequest(); - var randomCarId = Guid.NewGuid(); + Guid randomCarId = Guid.NewGuid(); // Act HttpResponseMessage response = await _factory.HttpClient.PutAsJsonAsync($"v1/cars/{randomCarId}", updateCarRequest); diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/CreateConsumptionTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/CreateConsumptionTests.cs index 123b24b..6783011 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/CreateConsumptionTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/CreateConsumptionTests.cs @@ -39,7 +39,7 @@ public class CreateConsumptionTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.Created); - var createdConsumption = await response.Content.ReadFromJsonAsync(); + CreateConsumption.Response? createdConsumption = await response.Content.ReadFromJsonAsync(); createdConsumption.Should().BeEquivalentTo(createConsumptionRequest, o => o.ExcludingMissingMembers()); _dbContext.Consumptions.Should().HaveCount(1) @@ -64,7 +64,7 @@ public class CreateConsumptionTests : IAsyncLifetime // Assert response.StatusCode.Should().Be(HttpStatusCode.BadRequest); - var validationProblemDetails = await response.Content.ReadFromJsonAsync(); + ValidationProblemDetails? validationProblemDetails = await response.Content.ReadFromJsonAsync(); validationProblemDetails!.Errors.Keys.Should().Contain(x => x.Equals(nameof(createConsumptionRequest.CarId), StringComparison.OrdinalIgnoreCase)); @@ -76,7 +76,7 @@ public class CreateConsumptionTests : IAsyncLifetime CreateCar.Request createCarRequest = new CarFaker().CreateCarRequest(); using HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); return createdCarResponse!; } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/DeleteConsumptionTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/DeleteConsumptionTests.cs index 113109a..9091ccd 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/DeleteConsumptionTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/DeleteConsumptionTests.cs @@ -43,7 +43,7 @@ public class DeleteConsumptionTests : IAsyncLifetime public async Task DeleteConsumption_ShouldReturnNotFound_WhenConsumptionDoesNotExist() { // Arrange - var consumptionId = Guid.NewGuid(); + Guid consumptionId = Guid.NewGuid(); // Act using HttpResponseMessage response = await _factory.HttpClient.DeleteAsync($"v1/consumptions/{consumptionId}"); @@ -58,7 +58,7 @@ public class DeleteConsumptionTests : IAsyncLifetime CreateConsumption.Request createConsumptionRequest = _consumptionFaker.CreateConsumptionRequest(createdCarResponse.Id); using HttpResponseMessage response = await _factory.HttpClient.PostAsJsonAsync("v1/consumptions", createConsumptionRequest); response.EnsureSuccessStatusCode(); - var createdConsumption = await response.Content.ReadFromJsonAsync(); + CreateConsumption.Response? createdConsumption = await response.Content.ReadFromJsonAsync(); return createdConsumption!; } @@ -67,7 +67,7 @@ public class DeleteConsumptionTests : IAsyncLifetime CreateCar.Request createCarRequest = new CarFaker().CreateCarRequest(); using HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); return createdCarResponse!; } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/GetConsumptionTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/GetConsumptionTests.cs index 8596d73..14dd412 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/GetConsumptionTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/GetConsumptionTests.cs @@ -37,7 +37,7 @@ public class GetConsumptionTests : IAsyncLifetime // Assert string content = await response.Content.ReadAsStringAsync(); response.StatusCode.Should().Be(HttpStatusCode.OK); - var consumption = await response.Content.ReadFromJsonAsync(); + GetConsumption.Response? consumption = await response.Content.ReadFromJsonAsync(); consumption.Should().BeEquivalentTo(createdConsumption); } @@ -45,7 +45,7 @@ public class GetConsumptionTests : IAsyncLifetime public async Task GetConsumptions_ShouldReturnNotFound_WhenConsumptionDoesNotExist() { // Arrange - var consumptionId = Guid.NewGuid(); + Guid consumptionId = Guid.NewGuid(); // Act using HttpResponseMessage response = await _factory.HttpClient.GetAsync($"v1/consumptions{consumptionId}"); @@ -60,7 +60,7 @@ public class GetConsumptionTests : IAsyncLifetime CreateConsumption.Request createConsumptionRequest = _consumptionFaker.CreateConsumptionRequest(createdCarResponse.Id); using HttpResponseMessage response = await _factory.HttpClient.PostAsJsonAsync("v1/consumptions", createConsumptionRequest); response.EnsureSuccessStatusCode(); - var createdConsumption = await response.Content.ReadFromJsonAsync(); + CreateConsumption.Response? createdConsumption = await response.Content.ReadFromJsonAsync(); return createdConsumption!; } @@ -69,7 +69,7 @@ public class GetConsumptionTests : IAsyncLifetime CreateCar.Request createCarRequest = new CarFaker().CreateCarRequest(); using HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); return createdCarResponse!; } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/UpdateConsumptionTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/UpdateConsumptionTests.cs index 9f0c1a6..09d0964 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/UpdateConsumptionTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Consumptions/UpdateConsumptionTests.cs @@ -39,7 +39,7 @@ public class UpdateConsumptionTests : IAsyncLifetime // Assert string content = await response.Content.ReadAsStringAsync(); response.StatusCode.Should().Be(HttpStatusCode.OK); - var updatedConsumption = await response.Content.ReadFromJsonAsync(); + UpdateConsumption.Response? updatedConsumption = await response.Content.ReadFromJsonAsync(); updatedConsumption.Should().BeEquivalentTo(updateConsumptionRequest, o => o.ExcludingMissingMembers()); _dbContext.Consumptions.Should().HaveCount(1) @@ -59,7 +59,7 @@ public class UpdateConsumptionTests : IAsyncLifetime // Arrange CreateConsumption.Response createdConsumption = await CreateConsumptionAsync(); UpdateConsumption.Request updateConsumptionRequest = _consumptionFaker.UpdateConsumptionRequest() with { Distance = -42 }; - var randomGuid = Guid.NewGuid(); + Guid randomGuid = Guid.NewGuid(); // Act using HttpResponseMessage response = await _factory.HttpClient.PutAsJsonAsync($"v1/consumptions/{randomGuid}", updateConsumptionRequest); @@ -67,7 +67,7 @@ public class UpdateConsumptionTests : IAsyncLifetime // Assert string content = await response.Content.ReadAsStringAsync(); response.StatusCode.Should().Be(HttpStatusCode.BadRequest); - var validationProblemDetails = await response.Content.ReadFromJsonAsync(); + ValidationProblemDetails? validationProblemDetails = await response.Content.ReadFromJsonAsync(); validationProblemDetails!.Errors.Keys.Should().Contain(x => x.Equals(nameof(updateConsumptionRequest.Distance), StringComparison.OrdinalIgnoreCase)); @@ -80,7 +80,7 @@ public class UpdateConsumptionTests : IAsyncLifetime // Arrange CreateConsumption.Response createdConsumption = await CreateConsumptionAsync(); UpdateConsumption.Request updateConsumptionRequest = _consumptionFaker.UpdateConsumptionRequest(); - var randomGuid = Guid.NewGuid(); + Guid randomGuid = Guid.NewGuid(); // Act using HttpResponseMessage response = await _factory.HttpClient.PutAsJsonAsync($"v1/consumptions/{randomGuid}", updateConsumptionRequest); @@ -98,7 +98,7 @@ public class UpdateConsumptionTests : IAsyncLifetime CreateConsumption.Request createConsumptionRequest = _consumptionFaker.CreateConsumptionRequest(createdCarResponse.Id); using HttpResponseMessage response = await _factory.HttpClient.PostAsJsonAsync("v1/consumptions", createConsumptionRequest); response.EnsureSuccessStatusCode(); - var createdConsumption = await response.Content.ReadFromJsonAsync(); + CreateConsumption.Response? createdConsumption = await response.Content.ReadFromJsonAsync(); return createdConsumption!; } @@ -107,7 +107,7 @@ public class UpdateConsumptionTests : IAsyncLifetime CreateCar.Request createCarRequest = new CarFaker().CreateCarRequest(); using HttpResponseMessage createCarResponse = await _factory.HttpClient.PostAsJsonAsync("v1/cars", createCarRequest); createCarResponse.EnsureSuccessStatusCode(); - var createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); + CreateCar.Response? createdCarResponse = await createCarResponse.Content.ReadFromJsonAsync(); return createdCarResponse!; } diff --git a/tests/Vegasco.Server.Api.Tests.Integration/Info/GetServerInfoTests.cs b/tests/Vegasco.Server.Api.Tests.Integration/Info/GetServerInfoTests.cs index 6c2f393..02cd58e 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/Info/GetServerInfoTests.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/Info/GetServerInfoTests.cs @@ -25,7 +25,7 @@ public class GetServerInfoTests // Assert response.IsSuccessStatusCode.Should().BeTrue(); - var serverInfo = await response.Content.ReadFromJsonAsync(); + GetServerInfo.Response? serverInfo = await response.Content.ReadFromJsonAsync(); serverInfo!.Environment.Should().NotBeEmpty(); serverInfo.CommitDate.Should().BeAfter(23.August(2024)) .And.NotBeAfter(DateTime.Now); diff --git a/tests/Vegasco.Server.Api.Tests.Integration/PostgresRespawner.cs b/tests/Vegasco.Server.Api.Tests.Integration/PostgresRespawner.cs index f852765..eed3a8d 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/PostgresRespawner.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/PostgresRespawner.cs @@ -19,7 +19,7 @@ internal sealed class PostgresRespawner : IDisposable DbConnection connection = new NpgsqlConnection(connectionString); await connection.OpenAsync(); - var respawner = await Respawner.CreateAsync(connection, + Respawner respawner = await Respawner.CreateAsync(connection, new RespawnerOptions { SchemasToInclude = ["public"],