Adding parameters to an Uri is an example where my NameValueCollectionHelper comes in handy. Although UriTemplate allows us to bind parameters, it doesn’t really support add/remove/fail on duplicate parameters. Here is an example

public void TestAddParametersReplaceWithReplaceOfExistingParameters()
	Uri originalUri = new Uri("")

	NameValueCollection parameters = new NameValueCollection();
	parameters.Add("key1", "newval");
	parameters.Add("key3", "val3");

	Uri expected = new Uri("");

	Uri actual = UriHelper.AddParameters(originalUri, parameters, DuplicateKeyBehavior.Replace);
	Assert.AreEqual(expected, actual);

Once again, source of this class can be found at BeTimvwFramework.