Ejemplo n.º 1
0
        public void Benchmark_Razor_vs_Markdown()
        {
            var iterations = 10000;
            var razorFormat = RazorFormat.Instance;
            var markdownFmt = MarkdownFormat.Instance;
            var dto = new RockstarsResponse { Results = Rockstar.SeedData.ToList() };

            "Warm up MVC Razor...".Print();
            var mockReq = new MockHttpRequest { OperationName = "RockstarsRazor" };
            var mockRes = new MockHttpResponse();
            razorFormat.ProcessRequest(mockReq, mockRes, dto);
            mockRes.ReadAsString().Print();

            "Warm up Markdown Razor...".Print();
            mockReq = new MockHttpRequest { OperationName = "RockstarsMark" };
            mockRes = new MockHttpResponse();
            markdownFmt.ProcessRequest(mockReq, mockRes, dto);
            mockRes.ReadAsString().Print();

            "\n\nRunning for {0} times...".Fmt(iterations).Print();
            CompareRuns(iterations,
                "MVC Razor", () => {
                    mockReq = new MockHttpRequest { OperationName = "RockstarsRazor" };
                    mockRes = new MockHttpResponse();
                    razorFormat.ProcessRequest(mockReq, mockRes, dto);
                },
                "Markdown Razor", () => {
                    mockReq = new MockHttpRequest { OperationName = "RockstarsMark" };
                    mockRes = new MockHttpResponse();
                    markdownFmt.ProcessRequest(mockReq, mockRes, dto);
                });
        }
 private static string GetRazorInstanceHtml()
 {
     var razorFormat = RazorFormat.Instance;
     var mockReq = new MockHttpRequest {OperationName = "RazorInstance"};
     var mockRes = new MockHttpResponse();
     var dto = new RockstarsResponse {Results = Rockstar.SeedData.ToList()};
     razorFormat.ProcessRequest(mockReq, mockRes, dto);
     var html = mockRes.ReadAsString();
     return html;
 }
Ejemplo n.º 3
0
        public MockRequestContext()
        {
            this.Cookies   = new Dictionary <string, Cookie>();
            this.Files     = new IFile[0];
            this.Container = new Container();
            var httpReq = new MockHttpRequest {
                Container = this.Container
            };

            httpReq.AddSessionCookies();
            this.Container.Register <IHttpRequest>(httpReq);
            var httpRes = new MockHttpResponse();

            this.Container.Register <IHttpResponse>(httpRes);
            httpReq.Container = this.Container;
        }