@@ -32,26 +32,7 @@ public void Constructor_3input_WithInvalidParameters_ShouldThrowArgumentExceptio
3232 // Act & Assert
3333 Assert . Throws < ArgumentNullException > ( ( ) =>
3434 new AppConfigKey ( confiProfileId , flagKey , attributeKey ) ) ;
35- }
36-
37- [ Theory ]
38- [ InlineData ( "app1" , "env1" , "config1" ) ]
39- [ InlineData ( "my-app" , "my-env" , "my-config" ) ]
40- [ InlineData ( "APP" , "ENV" , "CONFIG" ) ]
41- public void ToString_ShouldReturnFormattedString (
42- string configProfileId , string flagKey , string attributeKey )
43- {
44- // Arrange
45- var key = new AppConfigKey ( configProfileId , flagKey , attributeKey ) ;
46-
47- // Act
48- var result = key . ToString ( ) ;
49-
50- // Assert
51- Assert . Contains ( configProfileId , result ) ;
52- Assert . Contains ( flagKey , result ) ;
53- Assert . Contains ( attributeKey , result ) ;
54- }
35+ }
5536
5637 [ Theory ]
5738 [ InlineData ( "app-123" , "env-123" , "config-123" ) ]
@@ -146,29 +127,23 @@ public void Constructor_WithThreeParts_SetsPropertiesCorrectly()
146127 Assert . True ( appConfigKey . HasAttribute ) ;
147128 }
148129
149- [ Fact ]
150- public void Constructor_WithMoreThanThreeParts_IgnoresExtraParts ( )
151- {
152- // Arrange
153- var key = "profile123:flag456:attr789:extra:parts" ;
154-
155- // Act
156- var appConfigKey = new AppConfigKey ( key ) ;
157-
158- // Assert
159- Assert . Equal ( "profile123" , appConfigKey . ConfigurationProfileId ) ;
160- Assert . Equal ( "flag456" , appConfigKey . FlagKey ) ;
161- Assert . Equal ( "attr789" , appConfigKey . AttributeKey ) ;
162- Assert . True ( appConfigKey . HasAttribute ) ;
163- }
164-
165- [ Fact ]
166- public void Constructor_WithEmptyParts_ThrowsArgumentException ( )
130+ [ Theory ]
131+ [ InlineData ( "profile123:flag456:attr789:extra:parts" ) ]
132+ [ InlineData ( "profile123::attr789:extra:parts" ) ]
133+ [ InlineData ( "profile123:flagkey456:" ) ]
134+ [ InlineData ( "profile123:" ) ]
135+ [ InlineData ( ":flagkey456" ) ]
136+ [ InlineData ( ":flagkey456:" ) ]
137+ [ InlineData ( "::attribute789" ) ]
138+ [ InlineData ( "::" ) ]
139+ [ InlineData ( ":::" ) ]
140+ [ InlineData ( "RandomSgring)()@*Q()*#Q$@#$" ) ]
141+ public void Constructor_WithInvalidPattern_ShouldThrowArgumentException ( string key )
167142 {
168143 // Act & Assert
169144 var exception = Assert . Throws < ArgumentException > ( ( ) => new AppConfigKey ( "::" ) ) ;
170145 Assert . Equal ( "Invalid key format. Flag key is expected in configurationProfileId:flagKey[:attributeKey] format" , exception . Message ) ;
171- }
146+ }
172147
173148 [ Theory ]
174149 [ InlineData ( "profile123::attr789" ) ]
@@ -179,23 +154,7 @@ public void Constructor_WithEmptyMiddleParts_PreservesNonEmptyParts(string key)
179154 // Act & Assert
180155 var exception = Assert . Throws < ArgumentException > ( ( ) => new AppConfigKey ( key ) ) ;
181156 Assert . Equal ( "Invalid key format. Flag key is expected in configurationProfileId:flagKey[:attributeKey] format" , exception . Message ) ;
182- }
183-
184- [ Fact ]
185- public void Constructor_WithTrailingSeparator_HandlesProperly ( )
186- {
187- // Arrange
188- var key = "profile123:flag456:" ;
189-
190- // Act
191- var appConfigKey = new AppConfigKey ( key ) ;
192-
193- // Assert
194- Assert . Equal ( "profile123" , appConfigKey . ConfigurationProfileId ) ;
195- Assert . Equal ( "flag456" , appConfigKey . FlagKey ) ;
196- Assert . Null ( appConfigKey . AttributeKey ) ;
197- Assert . False ( appConfigKey . HasAttribute ) ;
198- }
157+ }
199158
200159 [ Fact ]
201160 public void Constructor_WithLeadingSeparator_ThrowsArgumentException ( )
@@ -267,4 +226,40 @@ public void HasAttribute_WhenConstructedWithStringWithoutAttribute_ReturnsFalse(
267226 // Act & Assert
268227 Assert . False ( appConfigKey . HasAttribute ) ;
269228 }
229+
230+ [ Theory ]
231+ [ InlineData ( "app1" , "env1" , "config1" ) ]
232+ [ InlineData ( "my-app" , "my-env" , "my-config" ) ]
233+ [ InlineData ( "APP" , "ENV" , "CONFIG" ) ]
234+ public void ToString_ShouldReturnFormattedString (
235+ string configProfileId , string flagKey , string attributeKey )
236+ {
237+ // Arrange
238+ var key = new AppConfigKey ( configProfileId , flagKey , attributeKey ) ;
239+
240+ // Act
241+ var result = key . ToString ( ) ;
242+
243+ // Assert
244+ Assert . Contains ( configProfileId , result ) ;
245+ Assert . Contains ( flagKey , result ) ;
246+ Assert . Contains ( attributeKey , result ) ;
247+ }
248+
249+ [ Theory ]
250+ [ InlineData ( "app1:env1:config1" ) ]
251+ [ InlineData ( "my-app:my-env:my-config" ) ]
252+ [ InlineData ( "APP:ENV" ) ]
253+ public void ToString_WithSingleInput_ShouldReturnFormattedString ( string input )
254+ {
255+ // Arrange
256+ var key = new AppConfigKey ( input ) ;
257+
258+ // Act
259+ var result = key . ToString ( ) ;
260+
261+ // Assert
262+ Assert . Contains ( key . ConfigurationProfileId , result ) ;
263+ Assert . Contains ( key . FlagKey , result ) ;
264+ }
270265}
0 commit comments