diff --git a/appveyor.yml b/appveyor.yml index a2aba10..c8d485c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,6 +23,6 @@ test_script: deploy: - provider: NuGet api_key: - secure: bGn7M6dHOJ3QjwYIv7e34tcY/n9cCUZmL1MnM6jRfmnJOOfwlrS+cdRj2n8Wf31n + secure: //tKHlb2yqAtpxnR6p9IAtXwQNaq8UYYyIFSD0QVF3XnEasIxG2gTWdmWuG87fUX on: appveyor_repo_tag: true \ No newline at end of file diff --git a/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs b/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs index 2448e81..1e7b67a 100644 --- a/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs +++ b/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs @@ -20,6 +20,13 @@ namespace FluentUriBuilder.Tests Assert.Throws(() => tstObj.WithParameter(parameterDictionary: null)); Assert.Throws(() => tstObj.WithFragment(fragmentDictionary: null)); Assert.Throws(() => tstObj.WithPort(-1)); + UriBuilder nullPtr = null; + Assert.Throws(()=>nullPtr.WithFragment("yo", "dawg")); + Assert.Throws(()=>nullPtr.WithParameter("yo", "dawg")); + Assert.Throws(()=>nullPtr.WithPathSegment("yo")); + Assert.Throws(()=>nullPtr.WithScheme("yo")); + Assert.Throws(()=>nullPtr.WithFragment("yo")); + Assert.Throws(()=>nullPtr.WithoutDefaultPort()); } } } \ No newline at end of file diff --git a/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj b/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj index 715e99b..4111cb6 100644 --- a/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj +++ b/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj @@ -1,6 +1,6 @@  - netcoreapp1.1;net461 + netcoreapp2.0;net461 diff --git a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs index 96540f4..eb04cc8 100644 --- a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs +++ b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs @@ -26,6 +26,10 @@ namespace System /// public static UriBuilder WithParameter(this UriBuilder bld, IDictionary parameterDictionary) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(parameterDictionary == null) throw new ArgumentNullException(nameof(parameterDictionary)); foreach(var item in parameterDictionary) { @@ -43,6 +47,10 @@ namespace System /// public static UriBuilder WithParameter(this UriBuilder bld, string key, IEnumerable valuesEnum) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); @@ -74,6 +82,10 @@ namespace System /// public static UriBuilder WithFragment(this UriBuilder bld, IDictionary fragmentDictionary) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(fragmentDictionary == null) throw new ArgumentNullException(nameof(fragmentDictionary)); foreach(var item in fragmentDictionary) { @@ -91,6 +103,10 @@ namespace System /// public static UriBuilder WithFragment(this UriBuilder bld, string key, IEnumerable valuesEnum) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); @@ -113,6 +129,10 @@ namespace System /// public static UriBuilder WithPort(this UriBuilder bld, int port) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(port < 1) throw new ArgumentOutOfRangeException(nameof(port)); bld.Port = port; return bld; @@ -125,6 +145,10 @@ namespace System /// public static UriBuilder WithoutDefaultPort(this UriBuilder bld) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if (bld.Uri.IsDefaultPort) bld.Port = -1; return bld; } @@ -138,6 +162,10 @@ namespace System /// public static UriBuilder WithPathSegment(this UriBuilder bld, string pathSegment) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(string.IsNullOrWhiteSpace(pathSegment)) { throw new ArgumentNullException(nameof(pathSegment)); @@ -156,6 +184,10 @@ namespace System /// public static UriBuilder WithScheme(this UriBuilder bld, string scheme) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(string.IsNullOrWhiteSpace(scheme)) throw new ArgumentNullException(nameof(scheme)); bld.Scheme = scheme; return bld; @@ -170,6 +202,10 @@ namespace System /// public static UriBuilder WithHost(this UriBuilder bld, string host) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } if(string.IsNullOrWhiteSpace(host)) throw new ArgumentNullException(nameof(host)); bld.Host = host; return bld; @@ -185,6 +221,10 @@ namespace System /// public static UriBuilder UseHttps(this UriBuilder bld, bool predicate = true) { + if(bld == null) + { + throw new ArgumentNullException(nameof(bld)); + } bld.Scheme = predicate ? "https" : "http"; return bld; } diff --git a/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj b/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj index 6e80dea..9102a5d 100644 --- a/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj +++ b/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj @@ -2,7 +2,7 @@ Tommy Parnell - netstandard1.1;net40;net45 + netstandard1.1;net40;net45;netstandard2.0 UriBuilder.Fluent UriBuilder.Fluent Url building;Uri;Uri building;fluent;extension