[d16-1] [Tests] Try different urls before failing the test. (#6266)

We do have a test that fails when there are issues accessing the remote
resource. We try diff urls to ensure that we are failing and is not due to the network.

Fixes: https://github.com/xamarin/maccore/issues/1725
This commit is contained in:
monojenkins 2019-06-12 11:33:53 -04:00 коммит произвёл Manuel de la Pena
Родитель c45bdd437c
Коммит 6bd94753f3
1 изменённых файлов: 20 добавлений и 3 удалений

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

@ -155,10 +155,27 @@ namespace MonoTouchFixtures.Foundation {
Assert.Ignore ("NSData.FromUrl doesn't seem to work in watchOS");
}
#endif
using (var url = new NSUrl ("https://www.microsoft.com/robots.txt"))
using (var x = NSData.FromUrl (url)) {
Assert.That ((x != null) && (x.Length > 0));
// we have network issues, try several urls, if one works, be happy, else fail
var urls = new string [] {
"https://www.microsoft.com/robots.txt",
"https://www.xamarin.com/robots.txt",
"http://www.bing.com/robots.txt",
"https://www.xbox.com/robots.txt",
"https://www.msn.com/robots.txt",
"https://visualstudio.microsoft.com/robots.txt",
};
for (var i = 0; i < urls.Length; i++) {
NSError error;
using (var nsUrl = new NSUrl (urls [i]))
using (var x = NSData.FromUrl (nsUrl, NSDataReadingOptions.Uncached, out error)) {
if (error != null)
continue;
Assert.That (x != null);
Assert.That (x.Length > 0);
return;
}
}
Assert.Fail ("None of the urls could be fetch.");
}
[Test]