From 60b47a45482df8e9afb05993d867dc73b7c4e5d5 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Sun, 12 Jun 2016 12:52:29 -0400 Subject: [PATCH] [tests][link sdk] Add tests to validate default properties for all (3) handlers that we ship --- .../link sdk/HttpClientHandlerTest.cs | 65 +++++++++++++++++++ tests/linker-ios/link sdk/link sdk.csproj | 2 + 2 files changed, 67 insertions(+) create mode 100644 tests/linker-ios/link sdk/HttpClientHandlerTest.cs diff --git a/tests/linker-ios/link sdk/HttpClientHandlerTest.cs b/tests/linker-ios/link sdk/HttpClientHandlerTest.cs new file mode 100644 index 000000000000..b4c11091900b --- /dev/null +++ b/tests/linker-ios/link sdk/HttpClientHandlerTest.cs @@ -0,0 +1,65 @@ +// Tests to ensure consistency of our handlers across updates +// +// Copyright 2016 Xamarin Inc. + +using System; +using System.Net; +using System.Net.Http; +#if XAMCORE_2_0 +using Foundation; +#else +using MonoTouch.Foundation; +#endif +using NUnit.Framework; + +namespace LinkSdk.Net.Http { + + [TestFixture] + [Preserve (AllMembers = true)] + public class HttpClientHandlerTest { + + [Test] + public void HttpClient () + { + using (var handler = new HttpClientHandler ()) { + Assert.True (handler.AllowAutoRedirect, "AllowAutoRedirect"); + Assert.NotNull (handler.CookieContainer, "CookieContainer"); + Assert.Null (handler.Credentials, "Credentials"); + // (so far) not exposed in other, native handlers + Assert.That (handler.AutomaticDecompression, Is.EqualTo (DecompressionMethods.None), "AutomaticDecompression"); + Assert.That (handler.ClientCertificateOptions, Is.EqualTo (ClientCertificateOption.Manual), "ClientCertificateOptions"); + Assert.That (handler.MaxAutomaticRedirections, Is.EqualTo (50), "MaxAutomaticRedirections"); + Assert.That (handler.MaxRequestContentBufferSize, Is.EqualTo (Int32.MaxValue), "MaxRequestContentBufferSize"); + Assert.Null (handler.Proxy, "Proxy"); + Assert.True (handler.SupportsAutomaticDecompression, "SupportsAutomaticDecompression"); + Assert.True (handler.SupportsProxy, "SupportsProxy"); + Assert.True (handler.SupportsRedirectConfiguration, "SupportsRedirectConfiguration"); + Assert.True (handler.UseCookies, "UseCookies"); + Assert.False (handler.UseDefaultCredentials, "UseDefaultCredentials"); + Assert.True (handler.UseProxy, "UseProxy"); + } + } + + [Test] + public void CFNetwork () + { + using (var handler = new CFNetworkHandler ()) { + Assert.True (handler.AllowAutoRedirect, "AllowAutoRedirect"); + Assert.NotNull (handler.CookieContainer, "CookieContainer"); + // custom, not in HttpClientHandler + Assert.False (handler.UseSystemProxy, "UseSystemProxy"); + } + } + + [Test] + public void NSUrlSession () + { + using (var handler = new NSUrlSessionHandler ()) { + Assert.True (handler.AllowAutoRedirect, "AllowAutoRedirect"); + Assert.Null (handler.Credentials, "Credentials"); + // custom, not in HttpClientHandler + Assert.False (handler.DisableCaching, "DisableCaching"); + } + } + } +} diff --git a/tests/linker-ios/link sdk/link sdk.csproj b/tests/linker-ios/link sdk/link sdk.csproj index 7d7cce5973b5..1c08194e32c7 100644 --- a/tests/linker-ios/link sdk/link sdk.csproj +++ b/tests/linker-ios/link sdk/link sdk.csproj @@ -26,6 +26,7 @@ -v -v -disable-thread-check -xml=${ProjectDir}/extra-linker-defs.xml i386 + SdkOnly none @@ -112,6 +113,7 @@ +