profileShare

rasmusjy / splitapp-backend-clean-onion

Read-only snapshot

No repository description.

main default branch 429 files Expires Sep 13, 2026, 9:06 AM
CurrencyConverterTests.cs 1,134 bytes
1 using App.BLL.Helpers;
2 using FluentAssertions;
3
4 namespace App.Tests.BLL;
5
6 public class CurrencyConverterTests
7 {
8 [Fact]
9 public void Convert_SameCurrency_ReturnsAmountUnchanged()
10 {
11 CurrencyConverter.Convert(100m, "EUR", "EUR").Should().Be(100m);
12 }
13
14 // Parameterized matrix of conversions — each row is one independent assertion
15 [Theory]
16 [InlineData(100, "USD", "EUR", 92.0)] // 100 USD * 0.92 = 92 EUR
17 [InlineData(100, "EUR", "USD", 108.70)] // 100 EUR / 0.92 = 108.6957 → 108.70
18 [InlineData(100, "GBP", "EUR", 116.0)] // 100 GBP * 1.16 = 116 EUR
19 public void Convert_KnownCurrencies_ReturnsCorrectExchange(decimal amount, string from, string to, decimal expected)
20 {
21 CurrencyConverter.Convert(amount, from, to).Should().Be(expected);
22 }
23
24 [Fact]
25 public void Convert_UnknownCurrency_FallsBackToOneToOne()
26 {
27 // Defensive default: "XYZ" not in rate table → return amount as-is rather than throw
28 CurrencyConverter.Convert(100m, "XYZ", "EUR").Should().Be(100m);
29 CurrencyConverter.Convert(100m, "EUR", "XYZ").Should().Be(100m);
30 }
31 }
32