Skip to content

Commit

Permalink
[Tests] Try different urls before failing the test. (#6237)
Browse files Browse the repository at this point in the history
We do have a test that fails when there are issues accessing the remote
resource. Try different urls to ensure that it is not a network issue with a specific domain.

Fixes: xamarin/maccore#1725
  • Loading branch information
mandel-macaque authored Jun 11, 2019
1 parent f25d591 commit 46c16eb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/monotouch-test/Foundation/NSDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,27 @@ public void Https ()
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]
Expand Down

0 comments on commit 46c16eb

Please sign in to comment.