Exemplo n.º 1
0
        public void Should_create_new_wrapper_from_html_response_if_not_already_present()
        {
            // Given
            var             called       = false;
            var             bodyBytes    = Encoding.ASCII.GetBytes("<html></html>");
            Action <Stream> bodyDelegate = (s) =>
            {
                s.Write(bodyBytes, 0, bodyBytes.Length);
                called = true;
            };
            var response = new Response {
                Contents = bodyDelegate
            };
            var context = new NancyContext()
            {
                Response = response
            };

            // When
            var result = context.DocumentBody();

            // Then
            result.ShouldBeOfType(typeof(DocumentWrapper));
            called.ShouldBeTrue();
        }
Exemplo n.º 2
0
        public void Should_use_documentwrapper_from_context_if_it_is_present()
        {
            var wrapper = new DocumentWrapper("<html></html>");
            var context = new NancyContext();
            context.Items["@@@@DOCUMENT_WRAPPER@@@@"] = wrapper; // Yucky hardcoded stringyness

            var result = context.DocumentBody();

            result.ShouldBeSameAs(wrapper);
        }
Exemplo n.º 3
0
        public void Should_use_documentwrapper_from_context_if_it_is_present()
        {
            var wrapper = new DocumentWrapper("<html></html>");
            var context = new NancyContext();

            context.Items["@@@@DOCUMENT_WRAPPER@@@@"] = wrapper; // Yucky hardcoded stringyness

            var result = context.DocumentBody();

            result.ShouldBeSameAs(wrapper);
        }
        public void Should_use_documentwrapper_from_context_if_it_is_present()
        {
            // Given
            var buffer =
                Encoding.UTF8.GetBytes("<html></html>");

            var wrapper = new DocumentWrapper(buffer);
            var context = new NancyContext();
            context.Items["@@@@DOCUMENT_WRAPPER@@@@"] = wrapper; // Yucky hardcoded stringyness

            // When
            var result = context.DocumentBody();

            // Then
            result.ShouldBeSameAs(wrapper);
        }
Exemplo n.º 5
0
        public void Should_use_documentwrapper_from_context_if_it_is_present()
        {
            // Given
            var buffer =
                Encoding.UTF8.GetBytes("<html></html>");

            var wrapper = new DocumentWrapper(buffer);
            var context = new NancyContext();

            context.Items["@@@@DOCUMENT_WRAPPER@@@@"] = wrapper; // Yucky hardcoded stringyness

            // When
            var result = context.DocumentBody();

            // Then
            result.ShouldBeSameAs(wrapper);
        }
Exemplo n.º 6
0
        public void Should_create_new_wrapper_from_html_response_if_not_already_present()
        {
            var called = false;
            var bodyBytes = Encoding.ASCII.GetBytes("<html></html>");
            Action<Stream> bodyDelegate = (s) =>
            {
                s.Write(bodyBytes, 0, bodyBytes.Length);
                called = true;
            };
            var response = new Response { Contents = bodyDelegate };
            var context = new NancyContext() { Response = response };

            var result = context.DocumentBody();

            result.ShouldBeOfType(typeof(DocumentWrapper));
            called.ShouldBeTrue();
        }