diff --git a/Tests/Singulink.Globalization.Currency.Tests/Sets/MoneySetTests/Ctor.cs b/Tests/Singulink.Globalization.Currency.Tests/Sets/MoneySetTests/Ctor.cs new file mode 100644 index 0000000..7d8da50 --- /dev/null +++ b/Tests/Singulink.Globalization.Currency.Tests/Sets/MoneySetTests/Ctor.cs @@ -0,0 +1,40 @@ +namespace Singulink.Globalization.Tests.Sets.MoneySetTests; + +[PrefixTestClass] +public class Ctor +{ + private static readonly Money Usd100 = new Money(100m, "USD"); + private static readonly ImmutableArray SetValues = [Usd100, new(50m, "CAD"), new(25m, "EUR")]; + + [TestMethod] + public void EmptyArray() + { + var set = new MoneySet(Array.Empty()); + set.Count.ShouldBe(0); + set.ShouldBe([]); + } + + [TestMethod] + public void SomeDefaultValues_IgnoresDefaultValues() + { + var set = new MoneySet([default, ..SetValues, default]); + set.Count.ShouldBe(3); + set.ShouldBe(SetValues, ignoreOrder: true); + } + + [TestMethod] + public void ZeroValues_SkipsIfPresent() + { + var set = new MoneySet([..SetValues, new(0m, "USD")]); + set.Count.ShouldBe(3); + set.ShouldBe(SetValues, ignoreOrder: true); + } + + [TestMethod] + public void MultipleSameCurrencyValues_AddsSameCurrencyValuesTogether() + { + var set = new MoneySet([..SetValues, ..SetValues, ..SetValues]); + set.Count.ShouldBe(3); + set.ShouldBe([new(300m, "USD"), new(150m, "CAD"), new(75m, "EUR")], ignoreOrder: true); + } +} \ No newline at end of file diff --git a/Tests/Singulink.Globalization.Currency.Tests/Sets/SortedMoneySet/Ctor.cs b/Tests/Singulink.Globalization.Currency.Tests/Sets/SortedMoneySet/Ctor.cs new file mode 100644 index 0000000..5ea1163 --- /dev/null +++ b/Tests/Singulink.Globalization.Currency.Tests/Sets/SortedMoneySet/Ctor.cs @@ -0,0 +1,40 @@ +namespace Singulink.Globalization.Tests.Sets.SortedMoneySetTests; + +[PrefixTestClass] +public class Ctor +{ + private static readonly Money Usd100 = new Money(100m, "USD"); + private static readonly ImmutableArray SetValues = [Usd100, new(50m, "CAD"), new(25m, "EUR")]; + + [TestMethod] + public void EmptyArray() + { + var set = new SortedMoneySet(Array.Empty()); + set.Count.ShouldBe(0); + set.ShouldBe([]); + } + + [TestMethod] + public void SomeDefaultValues_IgnoresDefaultValues() + { + var set = new SortedMoneySet([default, ..SetValues, default]); + set.Count.ShouldBe(3); + set.ShouldBe(SetValues, ignoreOrder: true); + } + + [TestMethod] + public void ZeroValues_SkipsIfPresent() + { + var set = new SortedMoneySet([..SetValues, new(0m, "USD")]); + set.Count.ShouldBe(3); + set.ShouldBe(SetValues, ignoreOrder: true); + } + + [TestMethod] + public void MultipleSameCurrencyValues_AddsSameCurrencyValuesTogether() + { + var set = new SortedMoneySet([..SetValues, ..SetValues, ..SetValues]); + set.Count.ShouldBe(3); + set.ShouldBe([new(300m, "USD"), new(150m, "CAD"), new(75m, "EUR")], ignoreOrder: true); + } +} \ No newline at end of file