-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from IowaComputerGurus/feature/int-format-support
Added support for format of int. #16
- Loading branch information
Showing
8 changed files
with
422 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
94 changes: 94 additions & 0 deletions
94
src/AspNetCore.Utilities.FontAwesomeTagHelpers.Tests/DateTimeFontAwesomeTagHelperTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ICG.AspNetCore.Utilities.FontAwesomeTagHelpers.Tests; | ||
|
||
public class DateTimeFontAwesomeTagHelperTests : TagHelperTestBase | ||
{ | ||
[Fact] | ||
public void ShouldRenderProperIconClass_WhenNull_WithDefaultConfiguration() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var expectedClass = "fas fa-minus"; | ||
|
||
//Act | ||
var helper = new DateTimeFontAwesomeIconTagHelper { Value = null }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal("span", output.TagName); | ||
Assert.Equal(expectedClass, output.Attributes["class"].Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldRenderProperIconClass_WhenNull_WithCustomConfiguration() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var expectedClass = "fas fa-times"; | ||
|
||
//Act | ||
var helper = new DateTimeFontAwesomeIconTagHelper { Value = null, NullValueIconClass = expectedClass }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal("span", output.TagName); | ||
Assert.Equal(expectedClass, output.Attributes["class"].Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldRenderProperTagName_WithCustomTagName() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var tagName = "i"; | ||
|
||
//Act | ||
var helper = new DateTimeFontAwesomeIconTagHelper { Value = null, Tag = tagName }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal(tagName, output.TagName); | ||
} | ||
|
||
[Fact] | ||
public void SHouldRenderProperValue_WhenNotNull() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var value = new DateTime(2022, 11, 15); | ||
|
||
//Act | ||
var helper = new DateTimeFontAwesomeIconTagHelper { Value = value }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal(value.ToString(), output.PostContent.GetContent()); | ||
} | ||
|
||
[Fact] | ||
public void SHouldRenderProperValue_WhenNotNull_WithFormatString() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var value = new DateTime(2022, 11, 15); | ||
var formatString = "MMdd"; | ||
var expectedValue = "1115"; | ||
|
||
//Act | ||
var helper = new DateTimeFontAwesomeIconTagHelper { Value = value, Format = formatString }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal(expectedValue, output.PostContent.GetContent()); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/AspNetCore.Utilities.FontAwesomeTagHelpers.Tests/DecimalFontAwesomeTagHelperTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ICG.AspNetCore.Utilities.FontAwesomeTagHelpers.Tests; | ||
|
||
public class DecimalFontAwesomeTagHelperTests : TagHelperTestBase | ||
{ | ||
[Fact] | ||
public void ShouldRenderProperIconClass_WhenNull_WithDefaultConfiguration() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var expectedClass = "fas fa-minus"; | ||
|
||
//Act | ||
var helper = new DecimalFontAwesomeIconTagHelper { Value = null }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal("span", output.TagName); | ||
Assert.Equal(expectedClass, output.Attributes["class"].Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldRenderProperIconClass_WhenNull_WithCustomConfiguration() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var expectedClass = "fas fa-times"; | ||
|
||
//Act | ||
var helper = new DecimalFontAwesomeIconTagHelper { Value = null, NullValueIconClass = expectedClass }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal("span", output.TagName); | ||
Assert.Equal(expectedClass, output.Attributes["class"].Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldRenderProperTagName_WithCustomTagName() | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
var tagName = "i"; | ||
|
||
//Act | ||
var helper = new DecimalFontAwesomeIconTagHelper { Value = null, Tag = tagName }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal(tagName, output.TagName); | ||
} | ||
|
||
[Theory] | ||
[InlineData(100, "", "100")] | ||
[InlineData(1000, "", "1000")] | ||
[InlineData(1000, "N1", "1,000.0")] | ||
public void SHouldRenderProperValue_WhenNotNull(decimal value, string formatString, string expectedValue) | ||
{ | ||
//Arrange | ||
var context = MakeTagHelperContext(); | ||
var output = MakeTagHelperOutput(" "); | ||
|
||
//Act | ||
var helper = new DecimalFontAwesomeIconTagHelper { Value = value, Format = formatString }; | ||
helper.Process(context, output); | ||
|
||
//Assert | ||
Assert.Equal(expectedValue, output.PostContent.GetContent()); | ||
} | ||
} | ||
|
Oops, something went wrong.