30 lines
1011 B
C#
30 lines
1011 B
C#
using ROLAC.API.Services.Disbursement;
|
|
using Xunit;
|
|
|
|
namespace ROLAC.API.Tests.Services;
|
|
|
|
public class AmountToWordsTests
|
|
{
|
|
[Theory]
|
|
[InlineData(0, "Zero and 00/100 Dollars")]
|
|
[InlineData(0.05, "Zero and 05/100 Dollars")]
|
|
[InlineData(1, "One and 00/100 Dollars")]
|
|
[InlineData(19, "Nineteen and 00/100 Dollars")]
|
|
[InlineData(20, "Twenty and 00/100 Dollars")]
|
|
[InlineData(21, "Twenty-One and 00/100 Dollars")]
|
|
[InlineData(100, "One Hundred and 00/100 Dollars")]
|
|
[InlineData(115, "One Hundred Fifteen and 00/100 Dollars")]
|
|
[InlineData(1234.56, "One Thousand Two Hundred Thirty-Four and 56/100 Dollars")]
|
|
[InlineData(1000000, "One Million and 00/100 Dollars")]
|
|
public void Convert_FormatsExpectedWords(double amount, string expected)
|
|
{
|
|
Assert.Equal(expected, AmountToWords.Convert((decimal)amount));
|
|
}
|
|
|
|
[Fact]
|
|
public void Convert_RoundsCentsHalfUp()
|
|
{
|
|
Assert.Equal("One and 00/100 Dollars", AmountToWords.Convert(0.999m));
|
|
}
|
|
}
|