@@ -158,6 +158,77 @@ public void Should_not_fail_if_undefined_value_is_not_an_allowed_value(string? i
158
158
Assert . Equal ( "allowed" , property . GetString ( source ) ) ;
159
159
}
160
160
161
+ [ Theory ]
162
+ [ InlineData ( "localhost.com/test" ) ]
163
+ [ InlineData ( "192.168.0.101" ) ]
164
+ [ InlineData ( "randomString" ) ]
165
+ public void Should_fail_if_url_is_invalid ( string ? input )
166
+ {
167
+ var source = new Dictionary < string , string >
168
+ {
169
+ [ "key" ] = input !
170
+ } ;
171
+
172
+ var property = new IntegrationProperty ( "key" , PropertyType . Text )
173
+ {
174
+ Format = PropertyFormat . HttpUrl
175
+ } ;
176
+
177
+ Assert . Throws < ValidationException > ( ( ) => property . GetString ( source ) ) ;
178
+ }
179
+
180
+ [ Theory ]
181
+ [ InlineData ( "http://192.168.0.101/" ) ]
182
+ [ InlineData ( "http://localhost/test" ) ]
183
+ [ InlineData ( "https://example.com/test?query=example" ) ]
184
+ [ InlineData ( "http://login:[email protected] /random" ) ]
185
+ public void Should_get_url_if_value_is_valid ( string ? input )
186
+ {
187
+ var source = new Dictionary < string , string >
188
+ {
189
+ [ "key" ] = input !
190
+ } ;
191
+
192
+ var property = new IntegrationProperty ( "key" , PropertyType . Text )
193
+ {
194
+ Format = PropertyFormat . HttpUrl
195
+ } ;
196
+
197
+ Assert . Equal ( input , property . GetString ( source ) ) ;
198
+ }
199
+
200
+ [ Fact ]
201
+ public void Should_fail_if_email_is_invalid ( )
202
+ {
203
+ var source = new Dictionary < string , string >
204
+ {
205
+ [ "key" ] = "invalidEmail"
206
+ } ;
207
+
208
+ var property = new IntegrationProperty ( "key" , PropertyType . Text )
209
+ {
210
+ Format = PropertyFormat . Email
211
+ } ;
212
+
213
+ Assert . Throws < ValidationException > ( ( ) => property . GetString ( source ) ) ;
214
+ }
215
+
216
+ [ Fact ]
217
+ public void Should_get_email_if_value_is_valid ( )
218
+ {
219
+ var source = new Dictionary < string , string >
220
+ {
221
+
222
+ } ;
223
+
224
+ var property = new IntegrationProperty ( "key" , PropertyType . Text )
225
+ {
226
+ Format = PropertyFormat . Email
227
+ } ;
228
+
229
+ Assert . Equal ( source [ "key" ] , property . GetString ( source ) ) ;
230
+ }
231
+
161
232
[ Fact ]
162
233
public void Should_get_value_if_all_requirements_are_met ( )
163
234
{
0 commit comments