forked from Sitecore/ASP.NET-Core-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Ensure culture-invariant date formatting for explicit formats and set test cultures #18
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
Open
Krishanthaudayakumara
wants to merge
15
commits into
main
Choose a base branch
from
fix/date-format-culture-invariant
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… test cultures - Updated DateTagHelper to use CultureInfo.InvariantCulture when DateFormat is specified and no explicit Culture is set, ensuring consistent date output regardless of system locale. - Explicitly set culture to en-US in RichTextFieldTagHelperFixture and other relevant integration test fixtures to make test expectations stable and independent of the developer's environment. - Updated test assertions to use the correct culture where appropriate. - Resolves test failures related to date formatting when running tests under non-US locales (e.g., da-DK).
…gHelperFixture.cs, extracting the culture selection logic into a separate variable for better readability in DateTagHelper.cs
…- Convert DateTagHelper unit tests to use InlineData pattern with multiple cultures
This reverts commit debfcde.
…ry operator" This reverts commit 30986a2.
…eFieldTagHelperFixture.cs, extracting the culture selection logic into a separate variable for better readability in DateTagHelper.cs" This reverts commit 979e588.
… and set test cultures" This reverts commit ccc68c7.
…ndency-injected instances
…ine Data Approach To main PR - Update date formatting tests to handle culture-specific formats - Inline Data Approach
Added missing metadata for Pages Assembly ## Description / Motivation The Pages package wasn't generating with any information, due to the missing meta data in the csproj ## Testing - [x] The Unit & Intergration tests are passing. - [x] I have added the necessary tests to cover my changes. ## Terms <!-- Place an X in the [] to check. --> <!-- The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it. --> - [x] I agree to follow this project's [Code of Conduct](CODE_OF_CONDUCT.md).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description / Motivation
Issue
encountered date formatting test failures when running the Sitecore ASP.NET Core SDK test suite with non-US locale settings (specifically Danish da-DK). The core issue was that date formatting was culture-dependent, causing tests to fail when the system culture used different date separators (dashes - vs slashes /).
Cause
DateTagHelper Implementation: Used CultureInfo.CurrentCulture for date formatting, making it dependent on system locale
Test Inconsistencies: Some tests expected invariant culture formatting while others expected current culture formatting
Integration Test Configuration: Missing explicit culture configuration in test fixtures, relying on system culture
Solution Implemented
string formattedDate = !string.IsNullOrWhiteSpace(DateFormat) ? field.Value.ToString(DateFormat, !string.IsNullOrWhiteSpace(Culture) ? culture : CultureInfo.InvariantCulture) : field.Value.ToString(culture);Behavior
Testing
Terms