@@ -358,18 +358,18 @@ public void IndexerTest ()
358358 }
359359
360360 [ Test ]
361- public void IndexerGetterThrowsKeyNotFoundTest ( )
361+ public void IndexerGetterKeyNotFoundBehaviorTest ( )
362362 {
363363 var value1 = NSDate . FromTimeIntervalSinceNow ( 1 ) ;
364364 var key1 = new NSString ( "key1" ) ;
365365 var keyMissing = new NSString ( "missing" ) ;
366366
367367 var dict = new NSMutableDictionary < NSString , NSDate > ( key1 , value1 ) ;
368368
369- // Accessing via the indexer property should throw KeyNotFoundException for missing keys
370- Assert . Throws < KeyNotFoundException > ( ( ) => GC . KeepAlive ( dict [ keyMissing ] ) , "missing key" ) ;
369+ // Accessing via the indexer property should return null
370+ Assert . IsNull ( dict [ keyMissing ] , "missing key" ) ;
371371
372- // But accessing via IDictionary interface should return null
372+ // Accessing via IDictionary interface should return null too
373373 IDictionary < NSString , NSDate > idict = dict ;
374374 Assert . IsNull ( idict [ keyMissing ] , "missing key via interface" ) ;
375375 }
@@ -399,10 +399,10 @@ public void MissingKeyAccessTest ()
399399 // ContainsKey should return false for missing keys
400400 Assert . IsFalse ( dict . ContainsKey ( keyMissing ) , "ContainsKey missing" ) ;
401401
402- // Indexer getter should throw KeyNotFoundException
403- Assert . Throws < KeyNotFoundException > ( ( ) => GC . KeepAlive ( dict [ keyMissing ] ) , "Indexer missing" ) ;
402+ // Indexer getter should return null
403+ Assert . IsNull ( dict [ keyMissing ] , "Indexer missing" ) ;
404404
405- // But IDictionary indexer should return null
405+ // IDictionary indexer should also return null
406406 IDictionary < NSString , NSDate > idict = dict ;
407407 Assert . IsNull ( idict [ keyMissing ] , "IDictionary indexer missing" ) ;
408408 }
@@ -421,7 +421,7 @@ public void EmptyDictionaryMissingKeyTest ()
421421 Assert . IsFalse ( dict . TryGetValue ( keyMissing , out value ) , "TryGetValue" ) ;
422422 Assert . IsNull ( value , "TryGetValue out" ) ;
423423
424- Assert . Throws < KeyNotFoundException > ( ( ) => GC . KeepAlive ( dict [ keyMissing ] ) , "Indexer" ) ;
424+ Assert . IsNull ( dict [ keyMissing ] , "Indexer" ) ;
425425
426426 IDictionary < NSString , NSDate > idict = dict ;
427427 Assert . IsNull ( idict [ keyMissing ] , "IDictionary indexer" ) ;
0 commit comments