From 0d45e050d1655623d5d922cc0bf63b8ff2f4d7a6 Mon Sep 17 00:00:00 2001 From: Mike Marynowski Date: Thu, 7 Mar 2024 01:57:58 -0500 Subject: [PATCH] Add ImmutabaleSortedMoneySet.RemoveAll tests for predicate overload --- .../ImmutableSortedMoneySetTests/RemoveAll.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Tests/Singulink.Globalization.Currency.Tests/ImmutableSortedMoneySetTests/RemoveAll.cs b/Tests/Singulink.Globalization.Currency.Tests/ImmutableSortedMoneySetTests/RemoveAll.cs index aa9494a..dee2ba1 100644 --- a/Tests/Singulink.Globalization.Currency.Tests/ImmutableSortedMoneySetTests/RemoveAll.cs +++ b/Tests/Singulink.Globalization.Currency.Tests/ImmutableSortedMoneySetTests/RemoveAll.cs @@ -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 @@ -13,8 +16,6 @@ public class RemoveAll private static readonly ImmutableSortedMoneySet Set = [Usd100, Cad50, Eur25]; - // public int RemoveAll(IEnumerable currencies) tests - [TestMethod] public void RemoveCurrencies_AllMatchingCurrencies_RemovesAllValues() { @@ -55,4 +56,19 @@ public void RemoveCurrencies_CurrencyDisallowed_ThrowsArgumentException() Should.Throw(() => 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); + } } \ No newline at end of file