Skip to content

Commit

Permalink
Add ImmutabaleSortedMoneySet.RemoveAll tests for predicate overload
Browse files Browse the repository at this point in the history
  • Loading branch information
mikernet committed Mar 7, 2024
1 parent c5435f4 commit 0d45e05
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Singulink.Globalization.Tests.ImmutableSortedMoneySetTests;
using System.Collections.Generic;
using System.Collections.Immutable;

namespace Singulink.Globalization.Tests.ImmutableSortedMoneySetTests;

[PrefixTestClass]
public class RemoveAll
Expand All @@ -13,8 +16,6 @@ public class RemoveAll

private static readonly ImmutableSortedMoneySet Set = [Usd100, Cad50, Eur25];

// public int RemoveAll(IEnumerable<Currency> currencies) tests

[TestMethod]
public void RemoveCurrencies_AllMatchingCurrencies_RemovesAllValues()
{
Expand Down Expand Up @@ -55,4 +56,19 @@ public void RemoveCurrencies_CurrencyDisallowed_ThrowsArgumentException()

Should.Throw<ArgumentException>(() => Set.RemoveAll([disallowedCurrency]));
}

[TestMethod]
public void RemoveCurrenciesByPredicate_SomeMatches_RemovesMatching()
{
var resultSet = Set.RemoveAll(m => m.Amount > 30);
resultSet.Count.ShouldBe(1);
resultSet.ShouldBe([Eur25]);
}

[TestMethod]
public void RemoveCurrenciesByPredicate_NoMatches_NoChange()
{
var resultSet = Set.RemoveAll(m => m.Amount > 100);
resultSet.ShouldBeSameAs(Set);
}
}

0 comments on commit 0d45e05

Please sign in to comment.