diff --git a/src/XlsxCompare.Tests/MatchByTests.cs b/src/XlsxCompare.Tests/MatchByTests.cs index 7dfb1b5..78fc252 100644 --- a/src/XlsxCompare.Tests/MatchByTests.cs +++ b/src/XlsxCompare.Tests/MatchByTests.cs @@ -19,6 +19,7 @@ public class MatchByTests [DataRow(MatchBy.StringLeftStartsWithRight, "asdf", "as")] [DataRow(MatchBy.Decimal, "0.084400", "0.0844")] [DataRow(MatchBy.Decimal, "0.00", "0")] + [DataRow(MatchBy.StringRightStartsWithLeft, "asdf", "asdf and then some")] public void IsMatch_ThingsThatMatch_ReturnsTrue(MatchBy? match, string left, string right) { Assert.IsTrue(match.IsMatch(left, right)); @@ -34,6 +35,8 @@ public void IsMatch_ThingsThatMatch_ReturnsTrue(MatchBy? match, string left, str [DataRow(MatchBy.StringLeftStartsWithRight, "as", "asdf")] [DataRow(MatchBy.StringLeftStartsWithRight, "asdf", "")] [DataRow(MatchBy.Decimal, "0.084400", "0.0845")] + [DataRow(MatchBy.StringRightStartsWithLeft, "", "asdf and then some")] + [DataRow(MatchBy.StringRightStartsWithLeft, "asdf but no", "asdf and then some")] public void IsMatch_ThingsThatDoNotMatch_ReturnsFalse(MatchBy? match, string left, string right) { Assert.IsFalse(match.IsMatch(left, right)); diff --git a/src/XlsxCompare/MatchBy.cs b/src/XlsxCompare/MatchBy.cs index 94b933e..38dc960 100644 --- a/src/XlsxCompare/MatchBy.cs +++ b/src/XlsxCompare/MatchBy.cs @@ -11,6 +11,7 @@ public enum MatchBy Decimal, Date, StringLeftStartsWithRight, + StringRightStartsWithLeft, } static class MatchByExtensions @@ -22,6 +23,7 @@ public static bool IsMatch(this MatchBy? match, string left, string right) MatchBy.Integer => IsIntegerMatch(left, right), MatchBy.StringIgnoreMissingLeft => left.Length == 0 || IsStringMatch(left, right), MatchBy.StringLeftStartsWithRight => IsLeftStartsWithRightMatch(left, right), + MatchBy.StringRightStartsWithLeft => IsLeftStartsWithRightMatch(right, left), MatchBy.Decimal => IsDecimalMatch(left, right), _ => IsStringMatch(left, right), };