public void OneParameterIsRead() { var qs = QueryString.FromUrl("http://example.com?name=value"); Assert.IsTrue(qs.Contains("name")); Assert.AreEqual("value", qs["name"]); }
public void ThreeParametersAreReadFromString() { var qs = QueryString.FromUrl("http://example.com?name1=value1&name2=value2&name3=value3"); Assert.IsTrue(qs.Contains("name1")); Assert.AreEqual("value1", qs["name1"]); Assert.IsTrue(qs.Contains("name2")); Assert.AreEqual("value2", qs["name2"]); Assert.IsTrue(qs.Contains("name3")); Assert.AreEqual("value3", qs["name3"]); }
public void DifferentUriTypesAreFine() { QueryString.FromUrl(new Uri("http://example.com?a=b", UriKind.Absolute)); QueryString.FromUrl(new Uri("index.html?a=b", UriKind.Relative)); QueryString.FromUrl(new Uri("index.html?a=b", UriKind.RelativeOrAbsolute)); // We also check all of them without the QS part. QueryString.FromUrl(new Uri("http://example.com", UriKind.Absolute)); QueryString.FromUrl(new Uri("index.html", UriKind.Relative)); QueryString.FromUrl(new Uri("index.html", UriKind.RelativeOrAbsolute)); }
public void ThreeParametersAreReadFromUri() { // Same as ThreeParametersAreReadFromString but using Uri as input (to ensure parsing works for all sources) var qs = QueryString.FromUrl(new Uri("http://example.com?name1=value1&name2=value2&name3=value3")); Assert.IsTrue(qs.Contains("name1")); Assert.AreEqual("value1", qs["name1"]); Assert.IsTrue(qs.Contains("name2")); Assert.AreEqual("value2", qs["name2"]); Assert.IsTrue(qs.Contains("name3")); Assert.AreEqual("value3", qs["name3"]); }
public void EmptyInEmptyOut() { var qs = QueryString.FromUrl("http://example.com/index"); Assert.AreEqual("?", qs.ToString()); }
public void EmptyStringIsFineAsUrl() { QueryString.FromUrl(""); }
public void StringUrlWithoutQueryStringIsFine() { QueryString.FromUrl("page.html"); }