public void EmptyCollection_ToEmptyString() { HttpNameValueCollection collection = new HttpNameValueCollection(); string result = collection.ToString(); Assert.AreEqual("", result); }
public void SingleValue_EncodesValue() { HttpNameValueCollection collection = new HttpNameValueCollection(); collection["a"] = " "; string result = collection.ToString(); Assert.AreEqual("a=%20", result); }
public void SingleValue_EncodesKey() { HttpNameValueCollection collection = new HttpNameValueCollection(); collection[" "] = "b"; string result = collection.ToString(); Assert.AreEqual("%20=b", result); }
public void SingleValue_ToKeyEqValue() { HttpNameValueCollection collection = new HttpNameValueCollection(); collection["a"] = "b"; string result = collection.ToString(); Assert.AreEqual("a=b", result); }
public void ParseEncodedString_EncodesWithDataEncoding() { HttpNameValueCollection collection = new HttpNameValueCollection(); collection["+"] = "+"; string result = collection.ToString(); Assert.AreEqual("%2B=%2B", result); }
public void TwoValues_ToKeyEqValueAmpSeparated() { HttpNameValueCollection collection = new HttpNameValueCollection(); collection["a"] = "b"; collection["c"] = "d"; string result = collection.ToString(); Assert.AreEqual("a=b&c=d", result); }
public void WhenChainingAdd_ThenCanContinueAdding() { var collection = new HttpNameValueCollection() .Add("tag", ".net") .Add("tag", "wpf") .Add("foo", "bar"); var query = collection.ToString(); Assert.True(query.IndexOf("tag") != query.LastIndexOf("tag"), "Tag should appear twice"); Assert.True(query.Contains("foo=bar")); }
public void WhenCreatingWithAnonymousAdd_ThenCanAddMultivalue() { var collection = new HttpNameValueCollection { { "tag", ".net", "wpf" }, { "foo", "bar" }, }; var query = collection.ToString(); Assert.True(query.IndexOf("tag") != query.LastIndexOf("tag"), "Tag should appear twice"); Assert.True(query.Contains("foo=bar")); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="values"></param> /// <param name="domain"></param> /// <param name="path"></param> /// <param name="expires"></param> /// <param name="secure"></param> public void Set(string name, HttpNameValueCollection values, string domain, string path, TimeSpan expires, bool secure, bool httpOnly) { name = Encode(name); //check if already exsits in response cookie? if (!_responseCookies.ContainsKey(name)) { if (_requestCookies.ContainsKey(name)) { if (_requestCookies[name].HasKeys) { foreach (string key in _requestCookies[name].Values.Keys) { if (!values.ContainsKey(key)) { values.Add(key, _requestCookies[name].Values[key]); } } } } } Save(name, values.ToString(), domain, path, expires, secure, httpOnly); }