Add tests
This commit is contained in:
1 parent
d5127c7405
commit
88aaaecb1a
15 files changed
+1755
-34
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using BudgetApp.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace BudgetApp.Tests.Models;
|
||||
|
||||
public class AccountModelTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("GBP", "£")]
|
||||
[InlineData("USD", "$")]
|
||||
[InlineData("EUR", "€")]
|
||||
[InlineData("JPY", "¥")]
|
||||
[InlineData("INR", "₹")]
|
||||
public void GetSymbol_KnownCurrency_ReturnsSymbol(string code, string expected)
|
||||
{
|
||||
var account = new Account { CurrencyCode = code };
|
||||
Assert.Equal(expected, account.GetSymbol());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSymbol_UnknownCurrency_ReturnsCurrencyCode()
|
||||
{
|
||||
var account = new Account { CurrencyCode = "XYZ" };
|
||||
Assert.Equal("XYZ", account.GetSymbol());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatAmount_FormatsWithSymbolAndTwoDecimals()
|
||||
{
|
||||
var account = new Account { CurrencyCode = "GBP" };
|
||||
Assert.Equal("£1,234.56", account.FormatAmount(1234.56m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatAmount_NegativeAmount_IncludesMinusSign()
|
||||
{
|
||||
var account = new Account { CurrencyCode = "USD" };
|
||||
Assert.Equal("$-50.00", account.FormatAmount(-50m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatAmount_Zero_FormatsCorrectly()
|
||||
{
|
||||
var account = new Account { CurrencyCode = "EUR" };
|
||||
Assert.Equal("€0.00", account.FormatAmount(0m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CurrencySymbols_ContainsExpectedCount()
|
||||
{
|
||||
Assert.Equal(20, Account.CurrencySymbols.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultValues_AreCorrect()
|
||||
{
|
||||
var account = new Account();
|
||||
Assert.Equal(string.Empty, account.Name);
|
||||
Assert.Equal(0m, account.CurrentBalance);
|
||||
Assert.Equal("#1b6ec2", account.Color);
|
||||
Assert.Equal("GBP", account.CurrencyCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user