Skip to content

Commit

Permalink
Merge pull request #1985 from jnyrup/RegexInvariantCulture
Browse files Browse the repository at this point in the history
Use InvariantCulture when doing case-insensitive matches
  • Loading branch information
jnyrup committed Sep 4, 2022
2 parents e62b97a + e1e15d7 commit 4422b73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Expand Up @@ -30,7 +30,7 @@ protected override void ValidateAgainstMismatch()

private bool IsMatch()
{
RegexOptions options = IgnoreCase ? RegexOptions.IgnoreCase : RegexOptions.None;
RegexOptions options = IgnoreCase ? (RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : RegexOptions.None;

string input = CleanNewLines(Subject);
string pattern = ConvertWildcardToRegEx(CleanNewLines(Expected));
Expand Down
Expand Up @@ -325,6 +325,14 @@ public void When_formatting_the_context_it_should_ignore_culture()
.WithMessage("*1.234*", "it should always use . as decimal separator");
}

[CulturedTheory("tr-TR")]
[MemberData(nameof(EquivalencyData))]
public void Matching_strings_for_equivalence_ignores_the_culture(string subject, string expected)
{
// Assert
subject.Should().MatchEquivalentOf(expected);
}

public static IEnumerable<object[]> EquivalencyData
{
get
Expand Down
1 change: 1 addition & 0 deletions docs/_pages/releases.md
Expand Up @@ -17,6 +17,7 @@ sidebar:

### Fixes
* Fixed `For`/`Exclude` not excluding properties in objects in a collection - [#1953](https://github.com/fluentassertions/fluentassertions/pull/1953)
* Changed `MatchEquivalentOf` to use `CultureInfo.InvariantCulture` instead of `CultureInfo.CurrentCulture` - [#1985](https://github.com/fluentassertions/fluentassertions/pull/1985).

## 6.7.0

Expand Down

0 comments on commit 4422b73

Please sign in to comment.