[monotouch-test] Second attempt at fixing the broken UrlRequestTest.Mutability_30744 test. (#9116)

This has been tested on:

* macOS 10.9, 10.10, 10.11, 10.12, 10.13, 10.14 and 10.15.
* iOS device:
	* iOS 8.2
	* iOS 9.3.5
	* iOS 11.4.1
	* iOS 13.6
This commit is contained in:
Rolf Bjarne Kvinge 2020-07-17 15:26:38 +02:00 коммит произвёл GitHub
Родитель c394c12c54
Коммит 026a58b6c4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -35,7 +35,19 @@ namespace MonoTouchFixtures.Foundation {
// that a bit like lying, we still consider it an NSMutableDictionary but it't not mutable
Assert.That (mur.Headers, Is.TypeOf (typeof (NSMutableDictionary)), "NSMutableDictionary");
mur.Headers.SetValueForKey (s3, s1);
var isActuallyMutable = TestRuntime.CheckXcodeVersion (8, 0);
if (isActuallyMutable) {
mur.Headers.SetValueForKey (s3, s1);
} else {
// In older OSes, the Headers is an instance of a class that's somehow immutable,
// even though it's an NSMutableDictionary subclass (specifically __NSCFDictionary).
// This feels like a bug that Apple fixed at some point.
#if __MACOS__
Assert.Throws<ObjCException> (() => mur.Headers.SetValueForKey (s3, s1));
#else
Assert.Throws<MonoTouchException> (() => mur.Headers.SetValueForKey (s3, s1));
#endif
}
// the original NSMutableDictionary is fine - but it's not what's being used, i.e. property is "copy"
md.Remove (s1);