Esempio n. 1
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");
        }
Esempio n. 2
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");
        }
Esempio n. 3
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=/");
        }
Esempio n. 4
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", true, true, 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));
        }
Esempio n. 5
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=/");
        }
Esempio n. 6
0
        public void Should_add_http_only_if_set_to_true()
        {
            var cookie = new NancyCookie("Test", "Value", true);

            var result = cookie.ToString();

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

            var result = cookie.ToString();

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

            var result = cookie.ToString();

            result.ShouldNotContain("Secure");
        }