public void CaseInSensitive() { FormDataCollection form = new FormDataCollection(new Uri("http://foo.com/?x=1&Y=2")); NameValueCollection nvc = form.ReadAsNameValueCollection(); Assert.Equal(2, nvc.Count); Assert.Equal("1", nvc.Get("x")); Assert.Equal("2", nvc.Get("y")); }
public void ToNameValueCollection() { FormDataCollection form = new FormDataCollection(new Uri("http://foo.com/?x=1a&y=2&x=1b&=ValueOnly&KeyOnly")); NameValueCollection nvc = form.ReadAsNameValueCollection(); // y=2 // x=1a;x=1b // =ValueOnly // KeyOnly Assert.Equal(4, nvc.Count); Assert.Equal(new string[] { "1a", "1b" }, nvc.GetValues("x")); Assert.Equal("1a,1b", nvc.Get("x")); Assert.Equal("2", nvc.Get("y")); Assert.Equal("", nvc.Get("KeyOnly")); Assert.Equal("ValueOnly", nvc.Get("")); }