コード例 #1
0
        public void DeleteCookieShouldSetDefaultPath()
        {
            var headers    = new HeaderDictionary();
            var cookies    = new ResponseCookies(headers, null);
            var testcookie = "TestCookie";

            cookies.Delete(testcookie);

            var cookieHeaderValues = headers[HeaderNames.SetCookie];

            Assert.Equal(1, cookieHeaderValues.Count);
            Assert.StartsWith(testcookie, cookieHeaderValues[0]);
            Assert.Contains("path=/", cookieHeaderValues[0]);
            Assert.Contains("expires=Thu, 01 Jan 1970 00:00:00 GMT", cookieHeaderValues[0]);
        }
コード例 #2
0
        public void NoParamsDeleteRemovesCookieCreatedByAdd()
        {
            var headers    = new HeaderDictionary();
            var cookies    = new ResponseCookies(headers, null);
            var testcookie = "TestCookie";

            cookies.Append(testcookie, testcookie);
            cookies.Delete(testcookie);

            var cookieHeaderValues = headers[HeaderNames.SetCookie];

            Assert.Equal(1, cookieHeaderValues.Count);
            Assert.StartsWith(testcookie, cookieHeaderValues[0]);
            Assert.Contains("path=/", cookieHeaderValues[0]);
            Assert.Contains("expires=Thu, 01 Jan 1970 00:00:00 GMT", cookieHeaderValues[0]);
        }
コード例 #3
0
        public void DeleteCookieShouldSetDefaultPath()
        {
            var headers    = (IHeaderDictionary) new HeaderDictionary();
            var features   = MakeFeatures(headers);
            var cookies    = new ResponseCookies(features);
            var testCookie = "TestCookie";

            cookies.Delete(testCookie);

            var cookieHeaderValues = headers.SetCookie;

            Assert.Single(cookieHeaderValues);
            Assert.StartsWith(testCookie, cookieHeaderValues[0]);
            Assert.Contains("path=/", cookieHeaderValues[0]);
            Assert.Contains("expires=Thu, 01 Jan 1970 00:00:00 GMT", cookieHeaderValues[0]);
        }
コード例 #4
0
        public void NoParamsDeleteRemovesCookieCreatedByAdd()
        {
            var headers    = (IHeaderDictionary) new HeaderDictionary();
            var features   = MakeFeatures(headers);
            var cookies    = new ResponseCookies(features);
            var testCookie = "TestCookie";

            cookies.Append(testCookie, testCookie);
            cookies.Delete(testCookie);

            var cookieHeaderValues = headers.SetCookie;

            Assert.Single(cookieHeaderValues);
            Assert.StartsWith(testCookie, cookieHeaderValues[0]);
            Assert.Contains("path=/", cookieHeaderValues[0]);
            Assert.Contains("expires=Thu, 01 Jan 1970 00:00:00 GMT", cookieHeaderValues[0]);
        }
コード例 #5
0
    public void DeleteWithExtensions()
    {
        var headers    = (IHeaderDictionary) new HeaderDictionary();
        var features   = MakeFeatures(headers);
        var cookies    = new ResponseCookies(features);
        var testCookie = "TestCookie";

        cookies.Delete(testCookie, new CookieOptions()
        {
            Extensions = { "simple", "key=value" }
        });

        var cookieHeaderValues = headers.SetCookie;

        Assert.Single(cookieHeaderValues);
        Assert.StartsWith(testCookie, cookieHeaderValues[0]);
        Assert.Contains("path=/", cookieHeaderValues[0]);
        Assert.Contains("expires=Thu, 01 Jan 1970 00:00:00 GMT", cookieHeaderValues[0]);
        Assert.Contains("simple;", cookieHeaderValues[0]);
        Assert.EndsWith("key=value", cookieHeaderValues[0]);
    }