Skip to content

Commit

Permalink
Finsh off code coverate for mutable set ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikernet committed Mar 8, 2024
1 parent cba56ee commit 5dab4da
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Money> SetValues = [Usd100, new(50m, "CAD"), new(25m, "EUR")];

[TestMethod]
public void EmptyArray()
{
var set = new MoneySet(Array.Empty<Money>());
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);
}
}
Original file line number Diff line number Diff line change
@@ -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<Money> SetValues = [Usd100, new(50m, "CAD"), new(25m, "EUR")];

[TestMethod]
public void EmptyArray()
{
var set = new SortedMoneySet(Array.Empty<Money>());
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);
}
}

0 comments on commit 5dab4da

Please sign in to comment.