-
Notifications
You must be signed in to change notification settings - Fork 0
Option 3 - fixed: Update date formatting tests to handle culture-specific formats #22
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||
| using System.Net; | ||||||
| using System.Globalization; | ||||||
| using System.Net; | ||||||
| using System.Text.Encodings.Web; | ||||||
| using FluentAssertions; | ||||||
| using HtmlAgilityPack; | ||||||
|
|
@@ -70,7 +71,8 @@ public async Task RichTextFieldTagHelper_DoesNotResetOtherTagHelperOutput() | |||||
|
|
||||||
| // Assert | ||||||
| // check scenario that RichTextTagHelper does not reset values of another helpers. | ||||||
| sectionNode.ChildNodes.First(n => n.Name.Equals("textarea", StringComparison.OrdinalIgnoreCase)).InnerText.Should().Contain("12/12/2019"); | ||||||
| DateTime expectedDate = DateTime.Parse("12.12.19", CultureInfo.InvariantCulture); | ||||||
|
||||||
| DateTime expectedDate = DateTime.Parse("12.12.19", CultureInfo.InvariantCulture); | |
| DateTime expectedDate = new DateTime(2019, 12, 12); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -123,23 +123,26 @@ public void Process_ScDateTagWithEmptyValueInForAttribute_GeneratesEmptyOutput( | |||||
| } | ||||||
|
|
||||||
| [Theory] | ||||||
| [AutoNSubstituteData] | ||||||
| public void Process_ScDateTagWithCustomFormat_GeneratesCustomDateFormatOutput( | ||||||
| DateTagHelper sut, | ||||||
| TagHelperContext tagHelperContext, | ||||||
| TagHelperOutput tagHelperOutput) | ||||||
| [InlineAutoNSubstituteData("en-US")] | ||||||
| [InlineAutoNSubstituteData("da-DK")] | ||||||
| [InlineAutoNSubstituteData("uk-UA")] | ||||||
| public void Process_ScDateTagWithCustomFormat_GeneratesCustomDateFormatOutput(string cultureName, DateTagHelper sut, TagHelperContext tagHelperContext, TagHelperOutput tagHelperOutput) | ||||||
| { | ||||||
| // Arrange | ||||||
| CultureInfo testCulture = new CultureInfo(cultureName); | ||||||
| const string dateFormat = "MM/dd/yyyy H:mm"; | ||||||
|
||||||
| const string dateFormat = "MM/dd/yyyy H:mm"; | |
| const string dateFormat = "yyyy-MM-dd HH:mm"; |
Copilot
AI
Aug 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded date format 'MM/dd/yyyy H:mm' may not work correctly across all cultures being tested. Consider using culture-specific format patterns or testing with formats that are more universal across the specified cultures (en-US, da-DK, uk-UA).
| string dateFormat = "MM/dd/yyyy H:mm"; | |
| string dateFormat = "yyyy-MM-dd HH:mm"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded date string '12.12.19' should be replaced with a more explicit format like '2019-12-12' or use DateTime constructor for better clarity and maintenance.