public void CopyToTest() { HttpCookieCollection col = new HttpCookieCollection(); HttpCookie[] cookies = new HttpCookie[2]; col.Add(new HttpCookie("cookie1", "value1")); col.Add(new HttpCookie("cookie2", "value2")); col.CopyTo(cookies, 0); Assert.AreEqual("cookie1", cookies[0].Name, "cookies[0].Name"); Assert.AreEqual("cookie2", cookies[1].Name, "cookies[1].Name"); }
private static void BuildCookiesInforString(HttpCookieCollection cookies, StringBuilder sb) { var cookiesArray = new HttpCookie[cookies.Count]; cookies.CopyTo(cookiesArray, 0); foreach (var cookie in cookiesArray) { sb.AppendLine("---COOKIE---"); sb.AppendLine("Name: " + cookie.Name); sb.AppendLine("Value: " + cookie.Value); sb.AppendLine("Path: " + cookie.Path); sb.AppendLine("Domain: " + cookie.Domain); } }
public void Deny_Unrestricted() { HttpCookieCollection jar = new HttpCookieCollection(); jar.Add(biscuit); jar.CopyTo(new object[1], 0); Assert.IsNull(jar.GetKey(0), "GetKey"); jar.Remove("chocolat"); jar.Set(biscuit); Assert.IsNotNull(jar.Get(0), "Get(int)"); Assert.IsNull(jar.Get("chocolat"), "Get(string)"); Assert.IsNotNull(jar[0], "this[int]"); Assert.IsNull(jar["chocolat"], "this[string]"); Assert.AreEqual(1, jar.AllKeys.Length, "AllKeys"); jar.Clear(); }
/// <summary> /// Copies members of the cookie collection to an <see cref="T:System.Array" /> beginning at the specified index of the /// array. /// </summary> /// <param name="dest">The destination <see cref="T:System.Array" />. </param> /// <param name="index">The index of the destination array where copying starts. </param> public void CopyTo(Array dest, int index) { collection.CopyTo(dest, index); }