Skip to content

Commit be5c60c

Browse files
Refactor: use [InlineAutoNSubstituteData] attributes and receive dependency-injected instances
1 parent f98096b commit be5c60c

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

tests/Sitecore.AspNetCore.SDK.RenderingEngine.Tests/TagHelpers/Fields/DateTagHelperFixture.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,15 @@ public void Process_ScDateTagWithEmptyValueInForAttribute_GeneratesEmptyOutput(
123123
}
124124

125125
[Theory]
126-
[InlineData("en-US")]
127-
[InlineData("da-DK")]
128-
[InlineData("uk-UA")]
129-
public void Process_ScDateTagWithCustomFormat_GeneratesCustomDateFormatOutput(string cultureName)
126+
[InlineAutoNSubstituteData("en-US")]
127+
[InlineAutoNSubstituteData("da-DK")]
128+
[InlineAutoNSubstituteData("uk-UA")]
129+
public void Process_ScDateTagWithCustomFormat_GeneratesCustomDateFormatOutput(string cultureName, DateTagHelper sut, TagHelperContext tagHelperContext, TagHelperOutput tagHelperOutput)
130130
{
131131
// Arrange
132132
CultureInfo testCulture = new CultureInfo(cultureName);
133133
const string dateFormat = "MM/dd/yyyy H:mm";
134134

135-
DateTagHelper sut = new DateTagHelper(new EditableChromeRenderer());
136-
TagHelperContext tagHelperContext = new TagHelperContext([], new Dictionary<object, object>(), Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
137-
TagHelperOutput tagHelperOutput = new TagHelperOutput(string.Empty, [], (_, _) =>
138-
{
139-
DefaultTagHelperContent tagHelperContent = new();
140-
return Task.FromResult<TagHelperContent>(tagHelperContent);
141-
});
142-
143135
tagHelperOutput.TagName = RenderingEngineConstants.SitecoreTagHelpers.DateHtmlTag;
144136
sut.DateFormat = dateFormat;
145137
sut.Culture = cultureName;
@@ -269,23 +261,15 @@ public void Process_ScDateTagWithAspDataAttributeWithEmptyValueInForAttribute_Ge
269261
}
270262

271263
[Theory]
272-
[InlineData("en-US")]
273-
[InlineData("da-DK")]
274-
[InlineData("uk-UA")]
275-
public void Process_ScDateTagWithAspDataAttributeWithCustomFormat_GeneratesCustomDateFormatOutput(string cultureName)
264+
[InlineAutoNSubstituteData("en-US")]
265+
[InlineAutoNSubstituteData("da-DK")]
266+
[InlineAutoNSubstituteData("uk-UA")]
267+
public void Process_ScDateTagWithAspDataAttributeWithCustomFormat_GeneratesCustomDateFormatOutput(string cultureName, DateTagHelper sut, TagHelperContext tagHelperContext, TagHelperOutput tagHelperOutput)
276268
{
277269
// Arrange
278270
CultureInfo testCulture = new CultureInfo(cultureName);
279271
string dateFormat = "MM/dd/yyyy H:mm";
280272

281-
DateTagHelper sut = new DateTagHelper(new EditableChromeRenderer());
282-
TagHelperContext tagHelperContext = new TagHelperContext([], new Dictionary<object, object>(), Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture));
283-
TagHelperOutput tagHelperOutput = new TagHelperOutput(string.Empty, [], (_, _) =>
284-
{
285-
DefaultTagHelperContent tagHelperContent = new();
286-
return Task.FromResult<TagHelperContent>(tagHelperContent);
287-
});
288-
289273
tagHelperOutput.TagName = RenderingEngineConstants.SitecoreTagHelpers.DateHtmlTag;
290274
sut.DateFormat = dateFormat;
291275
sut.Culture = cultureName;

0 commit comments

Comments
 (0)