Skip to content

Conversation

@einsteine89
Copy link

@einsteine89 einsteine89 commented Sep 5, 2025

This pull request introduces improvements to how numeric values are formatted for error messages and snapshot names, ensuring consistent, culture-invariant string representations. It also refactors some helper methods for clarity and static usage, and updates related test helpers.

Numeric value formatting improvements

  • Updated GetAcceptFieldValueString in AcceptMatchOperator.cs to format decimal, double, and float values using CultureInfo.InvariantCulture, ensuring consistent string output regardless of system locale.
  • Added similar formatting logic to the FormatInvariant helper in both AcceptAssert.cs test files, used for error message comparisons in tests. [1] [2]

Method refactoring and static usage

  • Changed CreateAcceptExceptionMessage and GetAcceptFieldValueString in AcceptMatchOperator.cs to be static methods, clarifying their usage and improving code readability. [1] [2]
  • Added using System.Globalization where necessary to support invariant formatting. [1] [2] [3]

Snapshot name generation

  • Refactored GetMethodSnapshotName in MSTestSnapshotFullNameReader.cs to use SnapshotNameExtension.Create(...).ToParamsString() for generating parameter strings, likely improving consistency and maintainability of snapshot names.

- Updated `MSTestSnapshotFullNameReader.cs` to generate more detailed snapshot names by incorporating parameter strings from data row attributes.
- Refactored methods in `AcceptMatchOperator.cs` to be static and improved `GetAcceptFieldValueString` with a switch expression for better readability and culture-invariant numeric formatting.
- Added `FormatInvariant` method in `AcceptAssert.cs` to standardize value formatting and improve error message clarity.
- Included `using System.Globalization;` in multiple files to support new formatting logic.
@swisslife-bot
Copy link
Contributor

swisslife-bot commented Sep 5, 2025

CLA assistant check
All committers have signed the CLA.

@einsteine89 einsteine89 marked this pull request as ready for review September 5, 2025 13:44
@glucaci glucaci requested a review from nscheibe December 22, 2025 07:52
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.

2 participants