summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.AspNet.Test/UriHelperTest.cs
blob: ea78a76204c6a744abf270175da85d5f64d57ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace DotNetOpenAuth.AspNet.Test {
	using System;
	using DotNetOpenAuth.AspNet.Clients;
	using NUnit.Framework;

	[TestFixture]
	public class UriHelperTest {
		[TestCase]
		public void TestAttachQueryStringParameterMethod() {
			// Arrange
			string[] input = new string[]
                                  {
                                      "http://x.com",
                                      "https://xxx.com/one?s=123",
                                      "https://yyy.com/?s=6&u=a",
                                      "https://zzz.com/default.aspx?name=sd"
                                  };

			string[] expectedOutput = new string[]
                                          {
                                              "http://x.com/?s=awesome",
                                              "https://xxx.com/one?s=awesome",
                                              "https://yyy.com/?s=awesome&u=a",
                                              "https://zzz.com/default.aspx?name=sd&s=awesome"
                                          };

			for (int i = 0; i < input.Length; i++) {
				// Act
				var inputUrl = new Uri(input[i]);
				var outputUri = UriHelper.AttachQueryStringParameter(inputUrl, "s", "awesome");

				// Assert
				Assert.AreEqual(expectedOutput[i], outputUri.ToString());
			}
		}
	}
}