Exemplo 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");
        }
Exemplo 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");
        }
Exemplo 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=/");
        }
Exemplo 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));
        }
Exemplo 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=/");
        }
Exemplo 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");
        }
Exemplo 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");
        }
Exemplo 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");
        }