64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using BudgetApp.Data.Entities;
|
|
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);
|
|
}
|
|
}
|