Skip to content

Make FluentValidation tests independent of host culture - #47

Merged
sinanbozkus merged 1 commit into
sinanbozkus:masterfrom
denizumur:fix/fluentvalidation-test-culture
Oct 26, 2026
Merged

sinanbozkus merged 1 commit into
sinanbozkus:masterfrom
denizumur:fix/fluentvalidation-test-culture

Conversation

@denizumur

Copy link
Copy Markdown
Contributor

Summary

Closes #46.

The FluentValidation test suite currently depends on the host machine's UI culture for tests that assert exact English validation messages.

This PR makes those tests deterministic without changing production behavior or FluentValidation localization.

Changes

  • Added a reusable UseCultureAttribute based on xUnit's BeforeAfterTestAttribute
  • Applied en-US to test classes that assert exact English validation messages
  • Enabled TestServer.PreserveExecutionContext for the shared server test host so request execution preserves the selected test culture
  • Kept Messages_are_localized_by_fluent_validation unchanged so explicit Turkish localization behavior remains covered

Validation

Reproduced under tr-TR before the fix:

  • .NET 6: 21 passed, 9 failed
  • .NET 8: 21 passed, 7 failed
  • .NET 10: 21 passed, 7 failed

After the fix:

  • .NET 6: 30/30 FluentValidation tests passed
  • .NET 8: 28/28 FluentValidation tests passed
  • .NET 10: 28/28 FluentValidation tests passed
  • Full solution tests passed on .NET 6, 8, and 10
  • git diff --check passed

.NET Core 3.1 builds successfully but could not be executed locally because the .NET Core 3.1 runtime is not installed.

No production code, validation messages, or package references were changed.

@sonarqubecloud

Copy link
Copy Markdown

@sinanbozkus
sinanbozkus merged commit d46189f into sinanbozkus:master Oct 26, 2026
7 checks passed
@sinanbozkus

Copy link
Copy Markdown
Owner

Thanks a lot for the report and the clean fix, @denizumur! Merged. Welcome aboard as a contributor 🎉

@denizumur
denizumur deleted the fix/fluentvalidation-test-culture branch October 26, 2026 21:35
@denizumur

Copy link
Copy Markdown
Contributor Author

Thank you! I really appreciate the review and the warm welcome. Happy to contribute — looking forward to helping again in the future! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FluentValidation tests depend on the host UI culture

2 participants