Inheritance: ForeverTransport
        public void ForeverFrameTransportEscapesTagsWithPersistentResponse(string data, string expected)
        {
            var request = MockRequest();
            var response = new CustomResponse();
            var context = new HostContext(request.Object, response);
            var fft = new ForeverFrameTransport(context, new DefaultDependencyResolver());

            AssertEscaped(fft, response, GetWrappedResponse(data), expected);
        }
        public void ForeverFrameTransportEscapesTags(string data, string expected)
        {
            var request = new Mock<IRequest>();
            var response = new CustomResponse();
            var context = new HostContext(request.Object, response);
            var fft = new ForeverFrameTransport(context, new DefaultDependencyResolver());

            AssertEscaped(fft, response, data, expected);
        }
        private static void AssertEscaped(ForeverFrameTransport fft, CustomResponse response, object input, string expectedOutput)
        {
            fft.Send(input).Wait();

            string rawResponse = response.GetData();
            response.Reset();

            // Doing contains due to all the stuff that gets sent through the buffer
            Assert.True(rawResponse.Contains(expectedOutput));
        }
        public void ForeverFrameTransportEscapesTags()
        {
            var request = new Mock<IRequest>();
            var response = new CustomResponse();
            var context = new HostContext(request.Object, response);
            var fft = new ForeverFrameTransport(context, new DefaultDependencyResolver());

            AssertEscaped(fft, response, "</sCRiPT>", "\\u003c/sCRiPT\\u003e");
            AssertEscaped(fft, response, "</SCRIPT dosomething='false'>", "\\u003c/SCRIPT dosomething='false'\\u003e");
            AssertEscaped(fft, response, "<p>ELLO</p>", "\\u003cp\\u003eELLO\\u003c/p\\u003e");
        }
        public void ForeverFrameTransportThrowsOnInvalidFrameId(string frameId)
        {
            var request = new Mock<IRequest>();
            var qs = new NameValueCollection { { "frameId", frameId } };
            request.Setup(r => r.QueryString).Returns(new NameValueCollectionWrapper(qs));
            var response = new CustomResponse();
            var context = new HostContext(request.Object, response);
            var connection = new Mock<ITransportConnection>();
            var fft = new ForeverFrameTransport(context, new DefaultDependencyResolver());

            Assert.Throws(typeof(InvalidOperationException), () => fft.InitializeResponse(connection.Object));
        }
        public void ForeverFrameTransportSetsCorrectContentType()
        {
            var request = new Mock<IRequest>();
            var qs = new NameValueCollection { { "frameId", "1" } };
            request.Setup(r => r.QueryString).Returns(new NameValueCollectionWrapper(qs));
            var response = new CustomResponse();
            var context = new HostContext(request.Object, response);
            var connection = new Mock<ITransportConnection>();
            var fft = new ForeverFrameTransport(context, new DefaultDependencyResolver());

            fft.InitializeResponse(connection.Object).Wait();

            Assert.Equal("text/html; charset=UTF-8", response.ContentType);
        }
 public ForeverFrameTransportContext(ForeverFrameTransport transport, object state)
 {
     Transport = transport;
     State     = state;
 }
 public ForeverFrameTransportContext(ForeverFrameTransport transport, object state)
 {
     Transport = transport;
     State = state;
 }
        private static void AssertEscaped(ForeverFrameTransport fft, MemoryStream ms, PersistentResponse input, string expectedOutput)
        {
            fft.Send(input).Wait();

            string rawResponse = Encoding.UTF8.GetString(ms.ToArray());

            // Doing contains due to all the stuff that gets sent through the buffer
            Assert.True(rawResponse.Contains(expectedOutput));
        }