Skip to content

Conversation

@Krishanthaudayakumara
Copy link
Owner

  • Convert DateTagHelper unit tests to use InlineData pattern with multiple cultures (en-US, da-DK, uk-UA)
  • Update integration tests to expect culture-aware date formatting instead of hardcoded US format
  • Fix test failures when running with Danish (da-dk) culture where date separator changes from "/" to "-"
  • Replace var declarations with explicit types in modified test methods
  • Add System.Globalization using statements where needed

Files modified,

  • DateTagHelperFixture.cs: Convert to multi-culture InlineData tests
  • DateFieldTagHelperFixture.cs: Use CurrentCulture for date expectations
  • AllFieldTagHelpersFixture.cs: Use CurrentCulture for date assertions
  • RichTextFieldTagHelperFixture.cs: Handle culture-specific date formatting
  • ViewFieldsBindingFixture.cs: Update date format expectations

…- Convert DateTagHelper unit tests to use InlineData pattern with multiple cultures

This comment was marked as outdated.

Comment on lines 136 to 143
TagHelperContext tagHelperContext = new TagHelperContext([], new Dictionary<object, object>(), Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
TagHelperOutput tagHelperOutput = new TagHelperOutput(string.Empty, [], (_, _) =>
{
DefaultTagHelperContent tagHelperContent = new();
return Task.FromResult<TagHelperContent>(tagHelperContent);
});

tagHelperOutput.TagName = RenderingEngineConstants.SitecoreTagHelpers.DateHtmlTag;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to new these up when they are added to the Fixture and can be passed in like the sut was previously?

Copy link
Owner Author

@Krishanthaudayakumara Krishanthaudayakumara Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this to - use [InlineAutoNSubstituteData] attributes and receive dependency injected instances.

Comment on lines 282 to 289
TagHelperContext tagHelperContext = new TagHelperContext([], new Dictionary<object, object>(), Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
TagHelperOutput tagHelperOutput = new TagHelperOutput(string.Empty, [], (_, _) =>
{
DefaultTagHelperContent tagHelperContent = new();
return Task.FromResult<TagHelperContent>(tagHelperContent);
});

tagHelperOutput.TagName = RenderingEngineConstants.SitecoreTagHelpers.DateHtmlTag;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again, these can be passed in from the fixture right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this to - use [InlineAutoNSubstituteData] attributes and receive dependency injected instances.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates date formatting tests to handle culture-specific formats, addressing test failures when running with different cultures like Danish (da-DK) where date separators change from "/" to "-".

  • Converts DateTagHelper unit tests to use InlineData pattern with multiple cultures (en-US, da-DK, uk-UA)
  • Updates integration tests to use CurrentCulture for date formatting instead of hardcoded US format
  • Adds explicit type declarations and required using statements for System.Globalization

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DateTagHelperFixture.cs Converts unit tests to multi-culture InlineData pattern with explicit culture handling
RichTextFieldTagHelperFixture.cs Updates date expectations to use CurrentCulture formatting
DateFieldTagHelperFixture.cs Replaces hardcoded date strings with culture-aware formatting
AllFieldTagHelpersFixture.cs Updates date field assertions to use CurrentCulture
ViewFieldsBindingFixture.cs Modifies date format expectations to handle culture differences

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{
// Arrange
CultureInfo testCulture = new CultureInfo(cultureName);
const string dateFormat = "MM/dd/yyyy H:mm";
Copy link

Copilot AI Aug 18, 2025

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).

Suggested change
const string dateFormat = "MM/dd/yyyy H:mm";
const string dateFormat = "yyyy-MM-dd HH:mm";

Copilot uses AI. Check for mistakes.
{
// Arrange
CultureInfo testCulture = new CultureInfo(cultureName);
string dateFormat = "MM/dd/yyyy H:mm";
Copy link

Copilot AI Aug 18, 2025

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).

Suggested change
string dateFormat = "MM/dd/yyyy H:mm";
string dateFormat = "yyyy-MM-dd HH:mm";

Copilot uses AI. Check for mistakes.
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.

3 participants