1 Commits
2.0.0 ... 2.1.0

Author SHA1 Message Date
Tommy Parnell
730ee07822 add tuple api back that was accidentally removed (#21) 2023-07-12 15:51:23 -04:00
5 changed files with 46 additions and 2 deletions

View File

@@ -35,6 +35,16 @@ namespace FluentUriBuilder.Tests
.WithParameter("awesome", "yodawg");
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]
public void PathAndQuery()

View File

@@ -18,6 +18,7 @@ namespace FluentUriBuilder.Tests
Assert.Throws<ArgumentNullException>(() => tstObj.WithScheme(null));
Assert.Throws<ArgumentNullException>(() => tstObj.WithHost(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<ArgumentOutOfRangeException>(() => tstObj.WithPort(-1));
UriBuilder nullPtr = null;
@@ -32,6 +33,7 @@ namespace FluentUriBuilder.Tests
Assert.Throws<ArgumentNullException>(() => nullPtr.WithPort(1));
Assert.Throws<ArgumentNullException>(() => nullPtr.WithHost("yo"));
Assert.Throws<ArgumentNullException>(() => nullPtr.UseHttps());
Assert.Throws<ArgumentNullException>(() => nullPtr.WithParameter((IEnumerable<(string, string)>)null));
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Text;
namespace System
{
public static class TerribleDevUriExtensions
public static partial class TerribleDevUriExtensions
{
/// <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.

View 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;
}
}
}

View File

@@ -24,7 +24,7 @@
<ItemGroup>
<None Include="..\..\Readme.md" 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>