Example #1
0
        public void Should_encode_key_and_value_when_stringified()
        {
            var cookie = new NancyCookie("Key with spaces", "Value with spaces");

            var result = cookie.ToString();

            result.ShouldEqual("Key+with+spaces=Value+with+spaces; path=/");
        }
Example #2
0
        public void Should_not_add_http_only_if_set_to_false()
        {
            var cookie = new NancyCookie("Test", "Value", false);

            var result = cookie.ToString();

            result.ShouldNotContain("HttpOnly");
        }
        public void Should_encode_key_and_value_when_stringified()
        {
            var cookie = new NancyCookie("Key with spaces", "Value with spaces");

            var result = cookie.ToString();

            result.ShouldEqual("Key+with+spaces=Value+with+spaces; path=/");
        }
Example #4
0
        public void Should_add_secure_if_set_to_true()
        {
            var cookie = new NancyCookie("Test", "Value", true, true);

            var result = cookie.ToString();

            result.ShouldContain("Secure");
        }
        public void Should_add_http_only_if_set_to_true()
        {
            var cookie = new NancyCookie("Test", "Value", true);

            var result = cookie.ToString();

            result.ShouldContain("HttpOnly");
        }
        public void Should_add_secure_if_set_to_true()
        {
            var cookie = new NancyCookie("Test", "Value", true, true);

            var result = cookie.ToString();

            result.ShouldContain("Secure");
        }
        public void Should_not_add_secure_if_set_to_false()
        {
            var cookie = new NancyCookie("Test", "Value", false, false);

            var result = cookie.ToString();

            result.ShouldNotContain("Secure");
        }
Example #8
0
        public void Should_stringify_a_domain()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm") { Domain = "google.com" };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/; domain=google.com");
        }
Example #9
0
        public void Should_stringify_a_path()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm") { Path = "/nancy" };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/nancy");
        }
Example #10
0
        public void Should_stringify_a_simple_name_value()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm");

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/");
        }
        public void Should_stringify_a_simple_name_value()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm");

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/");
        }
        public void Should_stringify_a_path()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm")
            {
                Path = "/nancy"
            };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/nancy");
        }
        public void Should_stringify_a_domain()
        {
            // Given
            var cookie = new NancyCookie("leto", "worm")
            {
                Domain = "google.com"
            };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual("leto=worm; path=/; domain=google.com");
        }
        public void Should_stringify_everyting()
        {
            // Given
            var date     = new DateTime(2016, 11, 8, 9, 10, 11, DateTimeKind.Utc);
            var tuesday  = GetInvariantAbbreviatedWeekdayName(date);
            var november = GetInvariantAbbreviatedMonthName(date);
            var cookie   = new NancyCookie("paul", "blind", true, true)
            {
                Expires = date, Path = "/frank", Domain = "gmail.com"
            };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual(string.Format("paul=blind; path=/frank; expires={0}, 08-{1}-2016 09:10:11 GMT; domain=gmail.com; Secure; HttpOnly", tuesday, november));
        }
Example #15
0
        public void Should_stringify_everyting()
        {
            // Given
            var date = new DateTime(2016, 11, 8, 9, 10, 11, DateTimeKind.Utc);
            var tuesday = GetInvariantAbbreviatedWeekdayName(date);
            var november = GetInvariantAbbreviatedMonthName(date);
            var cookie = new NancyCookie("paul", "blind") { Expires = date, Path = "/frank", Domain = "gmail.com" };

            // When
            var stringified = cookie.ToString();

            // Then
            stringified.ShouldEqual(string.Format("paul=blind; path=/frank; expires={0}, 08-{1}-2016 09:10:11 GMT; domain=gmail.com", tuesday, november));
        }
Example #16
0
        public void Should_not_add_secure_if_set_to_false()
        {
            var cookie = new NancyCookie("Test", "Value");

            var result = cookie.ToString();

            result.ShouldNotContain("Secure");
        }