2020-05-01 19:05:28 +01:00
|
|
|
using System;
|
2022-11-27 12:29:35 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-01 19:05:28 +01:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Tests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class URIExtensionTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void ApplyParameters_WithoutExistingParameters()
|
|
|
|
{
|
|
|
|
var expected = "http://google.com/?hello=world&nice=day";
|
2020-12-26 17:28:44 +00:00
|
|
|
var uri = new Uri("http://google.com/");
|
2020-05-01 19:05:28 +01:00
|
|
|
|
|
|
|
var parameters = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{ "hello", "world" },
|
|
|
|
{ "nice", "day" }
|
|
|
|
};
|
|
|
|
Assert.AreEqual(expected, uri.ApplyParameters(parameters).ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ApplyParameters_WithExistingParameters()
|
|
|
|
{
|
|
|
|
var expected = "http://google.com/?existing=paramter&hello=world&nice=day";
|
2020-12-26 17:28:44 +00:00
|
|
|
var uri = new Uri("http://google.com/?existing=paramter");
|
2020-05-01 19:05:28 +01:00
|
|
|
|
|
|
|
var parameters = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{ "hello", "world" },
|
|
|
|
{ "nice", "day" }
|
|
|
|
};
|
|
|
|
Assert.AreEqual(expected, uri.ApplyParameters(parameters).ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ApplyParameters_HandlesEscape()
|
|
|
|
{
|
|
|
|
var expected = "http://google.com/?existing=paramter&hello=%26world++";
|
2020-12-26 17:28:44 +00:00
|
|
|
var uri = new Uri("http://google.com/?existing=paramter");
|
2020-05-01 19:05:28 +01:00
|
|
|
|
|
|
|
var parameters = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{ "hello", "&world " },
|
|
|
|
};
|
|
|
|
Assert.AreEqual(expected, uri.ApplyParameters(parameters).ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|