public void CookieHelper_WhenNoClientSessionCookie_ReturnNull()
        {
            var context = new PartialHttpContext();

            var cookieHelper = new CookieHelper("test cookie");

            var result = cookieHelper.Gets(context);

            Assert.IsNull(result);
            Assert.AreEqual(0, context.Request.Cookies.Count);
        }
        public void CookieHelper_WhenClientSessionCookieExists_ReturnContent()
        {
            var content = "some content";

            var context = new PartialHttpContext();
            context.Request.Cookies.Add(new HttpCookie("test cookie", content));

            var helper = new CookieHelper("test cookie");
            var result = helper.Gets(context);

            Assert.IsNotNull(result);
            Assert.AreEqual(content, result);
        }
        public void CookieHelper_InsertClientSessionCookie()
        {
            var content = "some content";

            var context = new PartialHttpContext();

            var helper = new CookieHelper("test cookie");
            helper.Set(context, content);

            var result = context.Response.Cookies.Get("test cookie");

            Assert.AreEqual(result.Value, content);
        }
예제 #4
0
 /// <summary>
 /// 获取openid
 /// </summary>
 /// <returns></returns>
 public static string GetOpenID()
 {
     return(CookieHelper.GetCookieValue("_token_"));
 }