From fa8591981e19b047124d5139aeb109012a59989e Mon Sep 17 00:00:00 2001 From: Git History Editor Date: Thu, 25 May 2023 13:20:38 +0200 Subject: [PATCH] [tests] misc fixes --- .../HealthKit/HKWorkoutBuilderTest.cs | 2 + .../Network/NWResolutionReportTest.cs | 2 +- .../System.Net.Http/NetworkResources.cs | 60 +++++++++---------- .../UIKit/GestureRecognizerTest.cs | 7 +-- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/tests/monotouch-test/HealthKit/HKWorkoutBuilderTest.cs b/tests/monotouch-test/HealthKit/HKWorkoutBuilderTest.cs index b7e95df5ff57..798ebccb6880 100644 --- a/tests/monotouch-test/HealthKit/HKWorkoutBuilderTest.cs +++ b/tests/monotouch-test/HealthKit/HKWorkoutBuilderTest.cs @@ -31,6 +31,8 @@ public void GetSeriesBuilderNullReturnTest () { #if MONOMAC TestRuntime.AssertXcodeVersion (14, 0); +#else + TestRuntime.AssertXcodeVersion (11, 0); #endif var store = new HKHealthStore (); diff --git a/tests/monotouch-test/Network/NWResolutionReportTest.cs b/tests/monotouch-test/Network/NWResolutionReportTest.cs index 70cfa44820b0..19ad31d1733f 100644 --- a/tests/monotouch-test/Network/NWResolutionReportTest.cs +++ b/tests/monotouch-test/Network/NWResolutionReportTest.cs @@ -42,7 +42,7 @@ public void Init () connectedEvent = new AutoResetEvent (false); reportEvent = new AutoResetEvent (false); resolutionEvent = new AutoResetEvent (false); - host = NetworkResources.MicrosoftUri.Host; + host = NetworkResources.Httpbin.Uri.Host; // we create a connection which we are going to use to get the availabe // interfaces, that way we can later test protperties of the NWParameters class. using (var parameters = NWParameters.CreateUdp ()) diff --git a/tests/monotouch-test/System.Net.Http/NetworkResources.cs b/tests/monotouch-test/System.Net.Http/NetworkResources.cs index 66f0da266b79..a566b53be42b 100644 --- a/tests/monotouch-test/System.Net.Http/NetworkResources.cs +++ b/tests/monotouch-test/System.Net.Http/NetworkResources.cs @@ -5,35 +5,35 @@ namespace MonoTests.System.Net.Http { [Preserve (AllMembers = true)] public static class NetworkResources { - public static readonly string MicrosoftUrl = "https://www.microsoft.com"; - public static readonly Uri MicrosoftUri = new Uri (MicrosoftUrl); - public static readonly string MicrosoftHttpUrl = "http://www.microsoft.com"; - public static readonly string XamarinUrl = "https://dotnet.microsoft.com/apps/xamarin"; - public static readonly string XamarinHttpUrl = "http://dotnet.microsoft.com/apps/xamarin"; - public static readonly Uri XamarinUri = new Uri (XamarinUrl); - public static readonly string StatsUrl = "https://api.imgur.com/2/stats"; + public static string MicrosoftUrl => "https://www.microsoft.com"; + public static Uri MicrosoftUri => new Uri (MicrosoftUrl); + public static string MicrosoftHttpUrl => "http://www.microsoft.com"; + public static string XamarinUrl => "https://dotnet.microsoft.com/apps/xamarin"; + public static string XamarinHttpUrl => "http://dotnet.microsoft.com/apps/xamarin"; + public static Uri XamarinUri => new Uri (XamarinUrl); + public static string StatsUrl => "https://api.imgur.com/2/stats"; - public static readonly string [] HttpsUrls = { + public static string [] HttpsUrls => new [] { MicrosoftUrl, XamarinUrl, Httpbin.Url, }; - public static readonly string [] HttpUrls = { + public static string [] HttpUrls => new [] { MicrosoftHttpUrl, XamarinHttpUrl, Httpbin.HttpUrl, }; // Robots urls, useful when we want to get a small file - public static readonly string MicrosoftRobotsUrl = "https://www.microsoft.com/robots.txt"; - public static readonly string XamarinRobotsUrl = "https://www.xamarin.com/robots.txt"; - public static readonly string BingRobotsUrl = "http://www.bing.com/robots.txt"; - public static readonly string XboxRobotsUrl = "https://www.xbox.com/robots.txt"; - public static readonly string MSNRobotsUrl = "https://www.msn.com/robots.txt"; - public static readonly string VisualStudioRobotsUrl = "https://visualstudio.microsoft.com/robots.txt"; + public static string MicrosoftRobotsUrl => "https://www.microsoft.com/robots.txt"; + public static string XamarinRobotsUrl => "https://www.xamarin.com/robots.txt"; + public static string BingRobotsUrl => "http://www.bing.com/robots.txt"; + public static string XboxRobotsUrl => "https://www.xbox.com/robots.txt"; + public static string MSNRobotsUrl => "https://www.msn.com/robots.txt"; + public static string VisualStudioRobotsUrl => "https://visualstudio.microsoft.com/robots.txt"; - public static readonly string [] RobotsUrls = { + public static string [] RobotsUrls => new [] { MicrosoftRobotsUrl, XamarinRobotsUrl, BingRobotsUrl, @@ -43,22 +43,22 @@ public static class NetworkResources { }; public static class Httpbin { - public static readonly string Url = "https://httpbin.org"; - public static readonly Uri Uri = new Uri ("https://httpbin.org"); - public static readonly string DeleteUrl = "https://httpbin.org/delete"; - public static readonly string GetUrl = "https://httpbin.org/get"; - public static readonly string PatchUrl = "https://httpbin.org/patch"; - public static readonly string PostUrl = "https://httpbin.org/post"; - public static readonly string PutUrl = "https://httpbin.org/put"; - public static readonly string CookiesUrl = $"https://httpbin.org/cookies"; - public static readonly string HttpUrl = "http://httpbin.org"; + public static string Url { get { global::NUnit.Framework.Assert.Ignore ("httpbin is probably down"); return string.Empty; } } + public static Uri Uri => new Uri ($"{Url}"); + public static string DeleteUrl => $"{Url}/delete"; + public static string GetUrl => $"{Url}/get"; + public static string PatchUrl => $"{Url}/patch"; + public static string PostUrl => $"{Url}/post"; + public static string PutUrl => $"{Url}/put"; + public static string CookiesUrl => $"{Url}/cookies"; + public static string HttpUrl { get { global::NUnit.Framework.Assert.Ignore ("httpbin is probably down"); return string.Empty; } } - public static string GetAbsoluteRedirectUrl (int count) => $"https://httpbin.org/absolute-redirect/{count}"; - public static string GetRedirectUrl (int count) => $"https://httpbin.org/redirect/{count}"; - public static string GetRelativeRedirectUrl (int count) => $"https://httpbin.org/relative-redirect/{count}"; - public static string GetStatusCodeUrl (HttpStatusCode status) => $"http://httpbin.org/status/{(int) status}"; - public static string GetSetCookieUrl (string cookie, string value) => $"https://httpbin.org/cookies/set?{cookie}={value}"; + public static string GetAbsoluteRedirectUrl (int count) => $"{Url}/absolute-redirect/{count}"; + public static string GetRedirectUrl (int count) => $"{Url}/redirect/{count}"; + public static string GetRelativeRedirectUrl (int count) => $"{Url}/relative-redirect/{count}"; + public static string GetStatusCodeUrl (HttpStatusCode status) => $"{HttpUrl}/status/{(int) status}"; + public static string GetSetCookieUrl (string cookie, string value) => $"{Url}/cookies/set?{cookie}={value}"; public static string GetBasicAuthUrl (string username, string password) => $"{Url}/basic-auth/{username}/{password}"; } diff --git a/tests/monotouch-test/UIKit/GestureRecognizerTest.cs b/tests/monotouch-test/UIKit/GestureRecognizerTest.cs index 4ad48e598fa0..74333498d23c 100644 --- a/tests/monotouch-test/UIKit/GestureRecognizerTest.cs +++ b/tests/monotouch-test/UIKit/GestureRecognizerTest.cs @@ -15,6 +15,7 @@ using UIKit; using NUnit.Framework; using System.Threading; +using System.Threading.Tasks; namespace MonoTouchFixtures.UIKit { @@ -93,11 +94,9 @@ public void NoStrongCycles () [Test] public void GenericCallbackTest () { - var didRun = false; - var callbackEvent = new AutoResetEvent (false); + var callbackEvent = new TaskCompletionSource (); Action callback = (UITapGestureRecognizer _) => { - didRun = true; - callbackEvent.Set (); + callbackEvent.TrySetResult (true); }; using var recognizer = new UITapGestureRecognizer (callback);