Skip to content

Commit a267317

Browse files
committed
simplified to use test cases
1 parent 76d54f0 commit a267317

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

Our.Umbraco.TagHelpers.Tests/IncludeIfTagHelperTests.cs

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,27 @@ namespace Our.Umbraco.TagHelpers.Tests
99
{
1010
public class IncludeIfTagHelperTests
1111
{
12-
[Test]
13-
public async Task Given_True_Value_Return_Contents()
12+
[TestCase(true, "original-child-content", "original-child-content")]
13+
[TestCase(false, "original-child-content", "")]
14+
public async Task Given_Predicate_Return_Contents_Or_Empty(bool predicate, string childContent, string expected)
1415
{
1516
// Arrange
1617
var id = "unique-id";
17-
var childContent = "original-child-content";
1818
var tagHelperContext = GetTagHelperContext(id);
1919
var tagHelperOutput = GetTagHelperOutput(
2020
attributes: new TagHelperAttributeList(),
2121
childContent: childContent);
2222
tagHelperOutput.Content.SetContent(childContent);
2323

24-
var tagHelper = new IncludeIfTagHelper();
25-
tagHelper.Predicate = true;
24+
var tagHelper = new IncludeIfTagHelper { Predicate = predicate };
2625

2726
// Act
2827
await tagHelper.ProcessAsync(tagHelperContext, tagHelperOutput);
2928

3029
var content = tagHelperOutput.Content.GetContent();
31-
Console.WriteLine("Value:" + content);
3230

3331
// Assert
34-
Assert.AreEqual(childContent, tagHelperOutput.Content.GetContent());
35-
}
36-
37-
[Test]
38-
public async Task Given_False_Value_Return_Empty()
39-
{
40-
// Arrange
41-
var id = "unique-id";
42-
var childContent = "original-child-content";
43-
var tagHelperContext = GetTagHelperContext(id);
44-
var tagHelperOutput = GetTagHelperOutput(
45-
attributes: new TagHelperAttributeList(),
46-
childContent: childContent);
47-
tagHelperOutput.Content.SetContent(childContent);
48-
49-
var tagHelper = new IncludeIfTagHelper();
50-
tagHelper.Predicate = false;
51-
52-
// Act
53-
await tagHelper.ProcessAsync(tagHelperContext, tagHelperOutput);
54-
55-
var content = tagHelperOutput.Content.GetContent();
56-
Console.WriteLine("Value:" + content);
57-
58-
// Assert
59-
Assert.AreEqual(string.Empty, tagHelperOutput.Content.GetContent());
32+
Assert.AreEqual(expected, content);
6033
}
6134

6235
private static TagHelperContext GetTagHelperContext(string id = "testid")

0 commit comments

Comments
 (0)