@@ -247,7 +247,19 @@ public void CheckAudienceValues(GetPayloadValueTheoryData theoryData)
247
247
try
248
248
{
249
249
JsonWebToken jsonWebToken = new JsonWebToken ( theoryData . Json ) ;
250
- IdentityComparer . AreEqual ( jsonWebToken . Audiences , theoryData . PropertyValue , context ) ;
250
+ MethodInfo method = typeof ( JsonWebToken ) . GetMethod ( "GetPayloadValue" ) ;
251
+ MethodInfo generic = method . MakeGenericMethod ( theoryData . PropertyType ) ;
252
+ object [ ] parameters = new object [ ] { theoryData . PropertyName } ;
253
+ var audiences = generic . Invoke ( jsonWebToken , parameters ) ;
254
+
255
+ if ( ! IdentityComparer . AreEqual ( jsonWebToken . Audiences , theoryData . PropertyValue , context ) )
256
+ context . AddDiff ( $ "jsonWebToken.Audiences != theoryData.PropertyValue: '{ jsonWebToken . Audiences } ' != '{ theoryData . PropertyValue } '.") ;
257
+
258
+ if ( theoryData . ClaimValue != null )
259
+ if ( ! IdentityComparer . AreEqual ( audiences , theoryData . ClaimValue , context ) )
260
+ context . AddDiff ( $ "audiences != theoryData.ClaimValue: '{ audiences } ' != '{ theoryData . ClaimValue } '.") ;
261
+
262
+ theoryData . ExpectedException . ProcessNoException ( context ) ;
251
263
}
252
264
catch ( Exception ex )
253
265
{
@@ -263,31 +275,76 @@ public static TheoryData<GetPayloadValueTheoryData> CheckAudienceValuesTheoryDat
263
275
{
264
276
var theoryData = new TheoryData < GetPayloadValueTheoryData > ( ) ;
265
277
278
+ theoryData . Add ( new GetPayloadValueTheoryData ( "stringFromSingleInList" )
279
+ {
280
+ ClaimValue = "audience" ,
281
+ PropertyName = "aud" ,
282
+ PropertyType = typeof ( string ) ,
283
+ PropertyValue = new List < string > { "audience" } ,
284
+ Json = JsonUtilities . CreateUnsignedToken ( "aud" , new List < string > { "audience" } )
285
+ } ) ;
286
+
287
+ theoryData . Add ( new GetPayloadValueTheoryData ( "stringFromMultipeInList" )
288
+ {
289
+ ClaimValue = "audience" ,
290
+ ExpectedException = ExpectedException . ArgumentException ( "IDX14305:" ) ,
291
+ PropertyName = "aud" ,
292
+ PropertyValue = new List < string > { "audience" , "audience2" } ,
293
+ PropertyType = typeof ( string ) ,
294
+ Json = JsonUtilities . CreateUnsignedToken ( "aud" , new List < string > { "audience" , "audience2" } )
295
+ } ) ;
296
+
297
+ theoryData . Add ( new GetPayloadValueTheoryData ( "stringTwoNulloneNonNull" )
298
+ {
299
+ ClaimValue = "audience1" ,
300
+ PropertyName = "aud" ,
301
+ PropertyValue = new List < string > { "audience1" } ,
302
+ PropertyType = typeof ( string ) ,
303
+ Json = JsonUtilities . CreateUnsignedToken ( "aud" , new List < string > { null , "audience1" , null } )
304
+ } ) ;
305
+
306
+ theoryData . Add ( new GetPayloadValueTheoryData ( "stringFromCollection" )
307
+ {
308
+ ClaimValue = "audience" ,
309
+ PropertyName = "aud" ,
310
+ PropertyType = typeof ( string ) ,
311
+ PropertyValue = new Collection < string > { "audience" } ,
312
+ Json = JsonUtilities . CreateUnsignedToken ( "aud" , new Collection < string > { "audience" } )
313
+ } ) ;
314
+
266
315
theoryData . Add ( new GetPayloadValueTheoryData ( "singleNull" )
267
316
{
317
+ ClaimValue = new List < string > ( ) ,
268
318
PropertyName = "aud" ,
269
319
PropertyValue = new List < string > ( ) ,
320
+ PropertyType = typeof ( List < string > ) ,
270
321
Json = JsonUtilities . CreateUnsignedToken ( "aud" , null )
271
322
} ) ;
272
323
273
324
theoryData . Add ( new GetPayloadValueTheoryData ( "twoNull" )
274
325
{
326
+ ClaimValue = new List < string > ( ) ,
275
327
PropertyName = "aud" ,
276
328
PropertyValue = new List < string > ( ) ,
329
+ PropertyType = typeof ( List < string > ) ,
277
330
Json = JsonUtilities . CreateUnsignedToken ( "aud" , new List < string > { null , null } )
278
331
} ) ;
279
332
280
333
theoryData . Add ( new GetPayloadValueTheoryData ( "singleNonNull" )
281
334
{
335
+ ClaimValue = new List < string > { "audience" } ,
282
336
PropertyName = "aud" ,
283
337
PropertyValue = new List < string > { "audience" } ,
338
+ PropertyType = typeof ( List < string > ) ,
284
339
Json = JsonUtilities . CreateUnsignedToken ( "aud" , "audience" )
285
340
} ) ;
286
341
287
342
theoryData . Add ( new GetPayloadValueTheoryData ( "twoNulloneNonNull" )
288
343
{
344
+ ClaimValue = new List < string > { "audience1" } ,
289
345
PropertyName = "aud" ,
290
346
PropertyValue = new List < string > { "audience1" } ,
347
+ PropertyType = typeof ( List < string > ) ,
291
348
Json = JsonUtilities . CreateUnsignedToken ( "aud" , new List < string > { null , "audience1" , null } )
292
349
} ) ;
293
350
@@ -540,7 +597,7 @@ public static TheoryData<GetPayloadValueTheoryData> GetPayloadValueTheoryData
540
597
} ) ;
541
598
#endregion
542
599
543
- #region collection of strings form simple types
600
+ #region collection of strings from simple types
544
601
545
602
#region string[]
546
603
theoryData . Add ( new GetPayloadValueTheoryData ( "string[]dateTime" )
0 commit comments