Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Configure warnings as errors and fix resulting errors
  • Loading branch information
Ashleigh Adams authored and Ashleigh Adams committed Dec 8, 2025
commit 669cd3fb5729cb29d78c0c175ba0b1bc1fbed361
5 changes: 5 additions & 0 deletions jobs/Backend/Task/ExchangeRateProvider/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public async Task<ActionResult<IEnumerable<ExchangeRateDto>>> GetByCurrency(
[FromQuery] List<string>? quoteCurrencies,
CancellationToken cancellationToken = default)
{
logger.LogInformation("Received request to get exchange rates. BaseCurrency: {BaseCurrency}, QuoteCurrencies: {QuoteCurrencies}",
baseCurrency, quoteCurrencies is not null ? string.Join(", ", quoteCurrencies) : "null");

if (string.IsNullOrWhiteSpace(baseCurrency))
{
return BadRequest(new ProblemDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class CzkExchangeRateService(HttpClient httpClient, ILogger<CzkExchangeRa
{
public async Task<IList<ExchangeRate>>GetExchangeRatesAsync(Currency baseCurrency, CancellationToken cancellationToken = default)
{
logger.LogInformation("Fetching CZK exchange rates from external service.");

var response = await httpClient.GetAsync(new Uri("https://api.cnb.cz/cnbapi/exrates/daily?lang=EN"), cancellationToken);
response.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task GetByCurrency_WithQuoteCurrencies_PassesThemToHandlerAndReturn
A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.BaseCurrency.Code == baseCurrency &&
q.QuoteCurrencies.Count == 2 &&
q.QuoteCurrencies!.Count == 2 &&
q.QuoteCurrencies.Any(c => c.Code == "EUR") &&
q.QuoteCurrencies.Any(c => c.Code == "GBP")),
A<CancellationToken>._))
Expand All @@ -84,8 +84,8 @@ public async Task GetByCurrency_WithQuoteCurrencies_PassesThemToHandlerAndReturn

A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.QuoteCurrencies.Any(c => c.Code == "EUR") &&
q.QuoteCurrencies.Any(c => c.Code == "GBP")),
q.QuoteCurrencies!.Any(c => c.Code == "EUR") &&
q.QuoteCurrencies!.Any(c => c.Code == "GBP")),
A<CancellationToken>._))
.MustHaveHappenedOnceExactly();
}
Expand Down Expand Up @@ -161,8 +161,8 @@ public async Task GetByCurrency_WithUnsupportedBaseCurrency_ReturnsBadRequest()

var problemDetails = badRequestResult.Value.ShouldBeOfType<ProblemDetails>();
problemDetails.Title.ShouldBe("Unsupported base currency");
problemDetails.Detail.ShouldContain($"The currency '{unsupportedCurrency}' is not supported");
problemDetails.Detail.ShouldContain("Supported currencies:");
problemDetails.Detail!.ShouldContain($"The currency '{unsupportedCurrency}' is not supported");
problemDetails.Detail!.ShouldContain("Supported currencies:");
problemDetails.Status.ShouldBe(StatusCodes.Status400BadRequest);

A.CallTo(() => _fakeHandler.HandleAsync(A<GetExchangeRatesQuery>._, A<CancellationToken>._))
Expand Down Expand Up @@ -206,7 +206,7 @@ public async Task GetByCurrency_WithQuoteCurrenciesContainingEmptyStrings_Filter
A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.BaseCurrency.Code == baseCurrency &&
q.QuoteCurrencies.Count == 2),
q.QuoteCurrencies!.Count == 2),
A<CancellationToken>._))
.Returns(expectedRates);

Expand All @@ -218,7 +218,7 @@ public async Task GetByCurrency_WithQuoteCurrenciesContainingEmptyStrings_Filter

A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.QuoteCurrencies.Count == 2 &&
q.QuoteCurrencies!.Count == 2 &&
q.QuoteCurrencies.All(c => !string.IsNullOrWhiteSpace(c.Code))),
A<CancellationToken>._))
.MustHaveHappenedOnceExactly();
Expand Down Expand Up @@ -277,8 +277,8 @@ public async Task GetByCurrency_WithLowercaseQuoteCurrencies_ConvertsToUppercase

A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.QuoteCurrencies.Any(c => c.Code == "EUR") &&
q.QuoteCurrencies.Any(c => c.Code == "GBP")),
q.QuoteCurrencies!.Any(c => c.Code == "EUR") &&
q.QuoteCurrencies!.Any(c => c.Code == "GBP")),
A<CancellationToken>._))
.MustHaveHappenedOnceExactly();
}
Expand Down Expand Up @@ -328,7 +328,7 @@ public async Task GetByCurrency_WithValidThreeLetterQuoteCurrencies_PassesValida
result.Result.ShouldBeOfType<OkObjectResult>();

A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q => q.QuoteCurrencies.Count == 4),
A<GetExchangeRatesQuery>.That.Matches(q => q.QuoteCurrencies!.Count == 4),
A<CancellationToken>._))
.MustHaveHappenedOnceExactly();
}
Expand Down Expand Up @@ -357,7 +357,7 @@ public async Task GetByCurrency_WithMixedCaseValidQuoteCurrencies_ConvertsToUppe

A.CallTo(() => _fakeHandler.HandleAsync(
A<GetExchangeRatesQuery>.That.Matches(q =>
q.QuoteCurrencies.Count == 3 &&
q.QuoteCurrencies!.Count == 3 &&
q.QuoteCurrencies.All(c => c.Code == c.Code.ToUpperInvariant())),
A<CancellationToken>._))
.MustHaveHappenedOnceExactly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public void IsSupported_WithUnsupportedCurrency_ReturnsFalse(string currencyCode
}

[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void IsSupported_WithNullOrWhitespace_ReturnsFalse(string currencyCode)
Expand Down