Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use InvariantCulture when doing case-insensitive matches #1985

Merged
merged 1 commit into from Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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