4
4
using System . Collections . Generic ;
5
5
using System . Linq ;
6
6
using Microsoft . AspNet . Mvc . Rendering ;
7
- using Microsoft . AspNet . Mvc . TagHelpers . Internal ;
8
7
using Microsoft . AspNet . Razor . Runtime . TagHelpers ;
9
8
using Xunit ;
10
9
11
10
namespace Microsoft . AspNet . Mvc . TagHelpers
12
11
{
13
- public class TagHelperOutputHelperTest
12
+ public class tagHelperOutputTest
14
13
{
15
14
[ Theory ]
16
15
[ InlineData ( "hello" , "world" ) ]
@@ -30,7 +29,7 @@ public void RestoreBoundHtmlAttribute_RestoresOriginalAttributes(string attribut
30
29
var expectedAttribute = new KeyValuePair < string , string > ( attributeName , attributeValue ) ;
31
30
32
31
// Act
33
- TagHelperOutputHelper . RestoreBoundHtmlAttribute ( "hello" , tagHelperContext , tagHelperOutput ) ;
32
+ tagHelperOutput . RestoreBoundHtmlAttribute ( "hello" , tagHelperContext ) ;
34
33
35
34
// Assert
36
35
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -53,7 +52,7 @@ public void PullPrefixedAttributes_OnlyRemovesPrefixed_TagHelperOutputAttributeV
53
52
tagHelperOutput . Attributes . Add ( expectedAttribute ) ;
54
53
55
54
// Act
56
- var pulledAttributes = TagHelperOutputHelper . PullPrefixedAttributes ( "route-" , tagHelperOutput ) ;
55
+ var pulledAttributes = tagHelperOutput . PullPrefixedAttributes ( "route-" ) ;
57
56
58
57
// Assert
59
58
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -78,7 +77,7 @@ public void PullPrefixedAttributes_ReturnsEmpty_AttributeListIfNoAttributesPrefi
78
77
content : string . Empty ) ;
79
78
80
79
// Act
81
- var pulledAttributes = TagHelperOutputHelper . PullPrefixedAttributes ( "route-" , tagHelperOutput ) ;
80
+ var pulledAttributes = tagHelperOutput . PullPrefixedAttributes ( "route-" ) ;
82
81
83
82
// Assert
84
83
Assert . Empty ( pulledAttributes ) ;
@@ -103,7 +102,7 @@ public void MergeAttributes_DoesNotReplace_TagHelperOutputAttributeValues()
103
102
tagBuilder . Attributes . Add ( "type" , "hello" ) ;
104
103
105
104
// Act
106
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
105
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
107
106
108
107
// Assert
109
108
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -126,7 +125,7 @@ public void MergeAttributes_AppendsClass_TagHelperOutputAttributeValues()
126
125
var expectedAttribute = new KeyValuePair < string , string > ( "class" , "Hello btn" ) ;
127
126
128
127
// Act
129
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
128
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
130
129
131
130
// Assert
132
131
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -147,7 +146,7 @@ public void MergeAttributes_DoesNotEncode_TagHelperOutputAttributeValues()
147
146
tagBuilder . Attributes . Add ( expectedAttribute ) ;
148
147
149
148
// Act
150
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
149
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
151
150
152
151
// Assert
153
152
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -170,7 +169,7 @@ public void MergeAttributes_CopiesMultiple_TagHelperOutputAttributeValues()
170
169
tagBuilder . Attributes . Add ( expectedAttribute2 ) ;
171
170
172
171
// Act
173
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
172
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
174
173
175
174
// Assert
176
175
Assert . Equal ( 2 , tagHelperOutput . Attributes . Count ) ;
@@ -194,7 +193,7 @@ public void MergeAttributes_Maintains_TagHelperOutputAttributeValues()
194
193
var tagBuilder = new TagBuilder ( "p" ) ;
195
194
196
195
// Act
197
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
196
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
198
197
199
198
// Assert
200
199
var attribute = Assert . Single ( tagHelperOutput . Attributes ) ;
@@ -217,7 +216,7 @@ public void MergeAttributes_Combines_TagHelperOutputAttributeValues()
217
216
tagBuilder . Attributes . Add ( expectedBuilderAttribute ) ;
218
217
219
218
// Act
220
- TagHelperOutputHelper . MergeAttributes ( tagBuilder , tagHelperOutput ) ;
219
+ tagHelperOutput . MergeAttributes ( tagBuilder ) ;
221
220
222
221
// Assert
223
222
Assert . Equal ( tagHelperOutput . Attributes . Count , 2 ) ;
@@ -244,14 +243,16 @@ public void Merge_CombinesAllTagHelperOutputAndTagBuilderProperties()
244
243
tagBuilder . InnerHtml = "Hello from tagBuilder." ;
245
244
246
245
// Act
247
- TagHelperOutputHelper . Merge ( tagBuilder , tagHelperOutput ) ;
246
+ tagHelperOutput . Merge ( tagBuilder ) ;
248
247
249
248
// Assert
250
249
Assert . Equal ( "div" , tagHelperOutput . TagName ) ;
251
250
Assert . Equal ( "Hello from tagBuilder." , tagHelperOutput . Content ) ;
252
251
Assert . Equal ( tagHelperOutput . Attributes . Count , 2 ) ;
253
- Assert . Equal ( expectedOutputAttribute , tagHelperOutput . Attributes . First ( ) ) ;
254
- Assert . Equal ( expectedBuilderAttribute , tagHelperOutput . Attributes . Last ( ) ) ;
252
+ var attribute = Assert . Single ( tagHelperOutput . Attributes , kvp => kvp . Key . Equals ( "class" ) ) ;
253
+ Assert . Equal ( expectedOutputAttribute . Value , attribute . Value ) ;
254
+ attribute = Assert . Single ( tagHelperOutput . Attributes , kvp => kvp . Key . Equals ( "for" ) ) ;
255
+ Assert . Equal ( expectedBuilderAttribute . Value , attribute . Value ) ;
255
256
}
256
257
}
257
258
}
0 commit comments