@@ -9,54 +9,27 @@ namespace Our.Umbraco.TagHelpers.Tests
9
9
{
10
10
public class IncludeIfTagHelperTests
11
11
{
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 )
14
15
{
15
16
// Arrange
16
17
var id = "unique-id" ;
17
- var childContent = "original-child-content" ;
18
18
var tagHelperContext = GetTagHelperContext ( id ) ;
19
19
var tagHelperOutput = GetTagHelperOutput (
20
20
attributes : new TagHelperAttributeList ( ) ,
21
21
childContent : childContent ) ;
22
22
tagHelperOutput . Content . SetContent ( childContent ) ;
23
23
24
- var tagHelper = new IncludeIfTagHelper ( ) ;
25
- tagHelper . Predicate = true ;
24
+ var tagHelper = new IncludeIfTagHelper { Predicate = predicate } ;
26
25
27
26
// Act
28
27
await tagHelper . ProcessAsync ( tagHelperContext , tagHelperOutput ) ;
29
28
30
29
var content = tagHelperOutput . Content . GetContent ( ) ;
31
- Console . WriteLine ( "Value:" + content ) ;
32
30
33
31
// 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 ) ;
60
33
}
61
34
62
35
private static TagHelperContext GetTagHelperContext ( string id = "testid" )
0 commit comments