@@ -96,6 +96,33 @@ public Task SetParametersAsync(ParameterView parameters)
96
96
=> throw new NotImplementedException ( ) ;
97
97
}
98
98
99
+ public static IEnumerable < object [ ] > ComponentKeyTestData ( )
100
+ {
101
+ yield return new object [ ] { "test-string-key" , "test-string-key" } ;
102
+ yield return new object [ ] { 42 , "42" } ;
103
+ yield return new object [ ] { Guid . Parse ( "12345678-1234-1234-1234-123456789012" ) , "12345678-1234-1234-1234-123456789012" } ;
104
+ yield return new object [ ] { 123.45 , "123.45" } ;
105
+ yield return new object [ ] { new DateTime ( 2023 , 12 , 25 , 10 , 30 , 0 , DateTimeKind . Utc ) , "12/25/2023 10:30:00" } ;
106
+ yield return new object [ ] { null , string . Empty } ;
107
+ yield return new object [ ] { new object ( ) , string . Empty } ;
108
+ }
109
+
110
+ [ Theory ]
111
+ [ MemberData ( nameof ( ComponentKeyTestData ) ) ]
112
+ public void GetComponentMarkerKey_WorksWithVariousKeyTypes ( object componentKey , string expectedFormattedKey )
113
+ {
114
+ // Arrange
115
+ var httpContext = new DefaultHttpContext ( ) ;
116
+ var boundary = new SSRRenderModeBoundary ( httpContext , typeof ( TestComponent ) , new InteractiveServerRenderMode ( ) ) ;
117
+
118
+ // Act
119
+ var markerKey = boundary . GetComponentMarkerKey ( 1 , componentKey ) ;
120
+
121
+ // Assert
122
+ Assert . Equal ( expectedFormattedKey , markerKey . FormattedComponentKey ) ;
123
+ Assert . NotEmpty ( markerKey . LocationHash ) ;
124
+ }
125
+
99
126
class ServerRenderModeSubclass : InteractiveServerRenderMode { }
100
127
class WebAssemblyRenderModeSubclass : InteractiveWebAssemblyRenderMode { }
101
128
class AutoRenderModeSubclass : InteractiveAutoRenderMode { }
0 commit comments