Skip to content

Commit 277e1f0

Browse files
committed
Add extensive integration and unit tests for APIs and utilities
- Introduced new integration tests for `HolidayApi`, `InfoApi`, and other API endpoints. - Improved testing consistency by standardizing `CustomWebApplicationFactory` configuration. - Added utility tests for `DateOnlyJsonConverter`, `StringExtensions`, and `PaginationModel`. - Updated dependencies in `api.Tests.csproj` for testing frameworks and libraries. - Standardized `namespace` declarations and refactored redundant constructors across integration tests.
1 parent d1f6efa commit 277e1f0

26 files changed

+1074
-576
lines changed

api.Tests/ApiRoutesTests/AirportApiIntegrationTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using api.Models;
21
using System.Net.Http.Json;
2+
using api.Models;
33
using api.Utils;
44

5+
namespace api.Tests.ApiRoutesTests;
6+
57
public class AirportApiIntegrationTests : IClassFixture<CustomWebApplicationFactory>
68
{
79
private readonly HttpClient _client;

api.Tests/ApiRoutesTests/CategoryNaturalAreaApiIntegrationTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
using System.Net.Http.Json;
22
using api.Models;
33

4+
namespace api.Tests.ApiRoutesTests;
5+
46
public class CategoryNaturalAreaApiIntegrationTests : IClassFixture<CustomWebApplicationFactory> , IDisposable
57
{
6-
private readonly HttpClient _client;
7-
8-
public CategoryNaturalAreaApiIntegrationTests()
9-
{
10-
_client = new CustomWebApplicationFactory().CreateClient();
11-
}
8+
private readonly HttpClient _client = new CustomWebApplicationFactory().CreateClient();
129

1310
public void Dispose()
1411
{

api.Tests/ApiRoutesTests/CityApiIntegrationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using api.Models;
33
using api.Utils;
44

5+
namespace api.Tests.ApiRoutesTests;
6+
57
public class CityApiIntegrationTests : IClassFixture<CustomWebApplicationFactory> , IDisposable
68
{
79
private readonly HttpClient _client;

api.Tests/ApiRoutesTests/ConstitutionArticleApiIntegrationTests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
using api.Models;
33
using api.Utils;
44

5+
namespace api.Tests.ApiRoutesTests;
6+
57
public class ConstitutionArticleApiIntegrationTests : IClassFixture<CustomWebApplicationFactory>, IDisposable
68
{
7-
private readonly HttpClient _client;
8-
9-
public ConstitutionArticleApiIntegrationTests()
10-
{
11-
_client = new CustomWebApplicationFactory().CreateClient();
12-
}
9+
private readonly HttpClient _client = new CustomWebApplicationFactory().CreateClient();
1310

1411
public void Dispose()
1512
{
@@ -105,4 +102,4 @@ public async Task GetConstitutionArticlesByChapterNumber_ReturnsOkWithChapterDat
105102
Assert.Equal(2, result.Count);
106103
Assert.All(result, article => Assert.Equal(chapterNumber, article.ChapterNumber));
107104
}
108-
}
105+
}

api.Tests/ApiRoutesTests/CountryApiIntegrationTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
using api.Models;
21
using System.Net.Http.Json;
2+
using api.Models;
33

4-
public class CountryApiIntegrationTests : IClassFixture<CustomWebApplicationFactory>
5-
{
6-
private readonly HttpClient _client;
4+
namespace api.Tests.ApiRoutesTests;
75

8-
public CountryApiIntegrationTests(CustomWebApplicationFactory factory)
9-
{
10-
_client = factory.CreateClient();
11-
}
6+
public class CountryApiIntegrationTests(CustomWebApplicationFactory factory)
7+
: IClassFixture<CustomWebApplicationFactory>
8+
{
9+
private readonly HttpClient _client = factory.CreateClient();
1210

1311
[Fact]
1412
public async Task GetCountry_ReturnsAllCountryData()
@@ -26,4 +24,4 @@ public async Task GetCountry_ReturnsAllCountryData()
2624
Assert.Equal("$", result.CurrencySymbol);
2725
Assert.Equal("Peso", result.Currency);
2826
}
29-
}
27+
}

0 commit comments

Comments
 (0)