add tuple api back that was accidentally removed (#21)
This commit is contained in:
@@ -35,6 +35,16 @@ namespace FluentUriBuilder.Tests
|
|||||||
.WithParameter("awesome", "yodawg");
|
.WithParameter("awesome", "yodawg");
|
||||||
Assert.Equal("http://awesome.com/?awesome=yodawg", url.Uri.ToString());
|
Assert.Equal("http://awesome.com/?awesome=yodawg", url.Uri.ToString());
|
||||||
}
|
}
|
||||||
|
[Fact]
|
||||||
|
public void TestAddUrlParameterAsTupleList()
|
||||||
|
{
|
||||||
|
var url = new UriBuilder("http://awesome.com")
|
||||||
|
.WithParameter(new List<(string, string)>()
|
||||||
|
{
|
||||||
|
("awesome", "yodawg")
|
||||||
|
});
|
||||||
|
Assert.Equal("http://awesome.com/?awesome=yodawg", url.Uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PathAndQuery()
|
public void PathAndQuery()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace FluentUriBuilder.Tests
|
|||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithScheme(null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithScheme(null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithHost(null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithHost(null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter((IEnumerable<KeyValuePair<string, string>>)null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter((IEnumerable<KeyValuePair<string, string>>)null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithParameter((IEnumerable<(string, string)>)null));
|
||||||
Assert.Throws<ArgumentNullException>(() => tstObj.WithFragment(fragmentDictionary: null));
|
Assert.Throws<ArgumentNullException>(() => tstObj.WithFragment(fragmentDictionary: null));
|
||||||
Assert.Throws<ArgumentOutOfRangeException>(() => tstObj.WithPort(-1));
|
Assert.Throws<ArgumentOutOfRangeException>(() => tstObj.WithPort(-1));
|
||||||
UriBuilder nullPtr = null;
|
UriBuilder nullPtr = null;
|
||||||
@@ -32,6 +33,7 @@ namespace FluentUriBuilder.Tests
|
|||||||
Assert.Throws<ArgumentNullException>(() => nullPtr.WithPort(1));
|
Assert.Throws<ArgumentNullException>(() => nullPtr.WithPort(1));
|
||||||
Assert.Throws<ArgumentNullException>(() => nullPtr.WithHost("yo"));
|
Assert.Throws<ArgumentNullException>(() => nullPtr.WithHost("yo"));
|
||||||
Assert.Throws<ArgumentNullException>(() => nullPtr.UseHttps());
|
Assert.Throws<ArgumentNullException>(() => nullPtr.UseHttps());
|
||||||
|
Assert.Throws<ArgumentNullException>(() => nullPtr.WithParameter((IEnumerable<(string, string)>)null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
public static class TerribleDevUriExtensions
|
public static partial class TerribleDevUriExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Appends a query string parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the QS.
|
/// Appends a query string parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the QS.
|
||||||
|
|||||||
32
src/UriBuilder.Fluent/TerribleDevUriExtensionsTuple.cs
Normal file
32
src/UriBuilder.Fluent/TerribleDevUriExtensionsTuple.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace System
|
||||||
|
{
|
||||||
|
public static partial class TerribleDevUriExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Appends query strings from dictionary
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bld"></param>
|
||||||
|
/// <param name="parameterDictionary"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UriBuilder WithParameter(this UriBuilder bld, IEnumerable<(string, string)> parameterDictionary)
|
||||||
|
{
|
||||||
|
if (bld == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(bld));
|
||||||
|
}
|
||||||
|
if (parameterDictionary == null) throw new ArgumentNullException(nameof(parameterDictionary));
|
||||||
|
foreach (var item in parameterDictionary)
|
||||||
|
{
|
||||||
|
bld.WithParameter(item.Item1, item.Item2);
|
||||||
|
}
|
||||||
|
return bld;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\Readme.md" Pack="true" PackagePath="\" />
|
<None Include="..\..\Readme.md" Pack="true" PackagePath="\" />
|
||||||
<None Include="..\..\UriBulider.Fluent.png" Pack="true" PackagePath="\" />
|
<None Include="..\..\UriBulider.Fluent.png" Pack="true" PackagePath="\" />
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user