示例#1
0
        public void PdfResultShouldWriteToOutputStream()
        {
            var settings   = new SparkSettings();
            var viewFolder = new InMemoryViewFolder
            {
                {
                    "foo/bar.spark",
                    HelloWorldXml
                }
            };
            var factory = new SparkViewFactory(settings)
            {
                ViewFolder = viewFolder
            };

            var stream            = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            var result = new PdfViewResult
            {
                ViewEngineCollection = new ViewEngineCollection(new[] { factory })
            };

            result.ExecuteResult(controllerContext);

            Assert.That(stream.Length, Is.Not.EqualTo(0));
        }
示例#2
0
        public void ContentTypeShouldBeApplicationPdf()
        {
            var stream = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            IView view;
            var viewEngine = MockViewEngine(controllerContext, out view);

            var result = new PdfViewResult
            {
                ViewName = "quux",
                ViewEngineCollection = new ViewEngineCollection(new[] { viewEngine })
            };

            result.ExecuteResult(controllerContext);

            Assert.That(controllerContext.HttpContext.Response.ContentType, Is.EqualTo("application/pdf"));
        }
示例#3
0
        public void ContentTypeShouldBeApplicationPdf()
        {
            var stream            = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            IView view;
            var   viewEngine = MockViewEngine(controllerContext, out view);


            var result = new PdfViewResult
            {
                ViewName             = "quux",
                ViewEngineCollection = new ViewEngineCollection(new[] { viewEngine })
            };

            result.ExecuteResult(controllerContext);

            Assert.That(controllerContext.HttpContext.Response.ContentType, Is.EqualTo("application/pdf"));
        }
示例#4
0
        public void PdfResultShouldFindPartialViewAndRenderIt()
        {
            var stream            = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            IView view;
            var   viewEngine = MockViewEngine(controllerContext, out view);

            var result = new PdfViewResult
            {
                ViewName             = "quux",
                ViewEngineCollection = new ViewEngineCollection(new[] { viewEngine })
            };

            result.ExecuteResult(controllerContext);

            viewEngine.VerifyAllExpectations();
            view.VerifyAllExpectations();
        }
示例#5
0
        public void PdfResultShouldFindPartialViewAndRenderIt()
        {
            var stream = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            IView view;
            var viewEngine = MockViewEngine(controllerContext, out view);

            var result = new PdfViewResult
                         {
                             ViewName = "quux",
                             ViewEngineCollection = new ViewEngineCollection(new[] { viewEngine })
                         };

            result.ExecuteResult(controllerContext);

            viewEngine.VerifyAllExpectations();
            view.VerifyAllExpectations();
        }
示例#6
0
        public void PdfResultShouldWriteToOutputStream()
        {
            var settings = new SparkSettings();
            var viewFolder = new InMemoryViewFolder
                             {
                                 {
                                     "foo/bar.spark",
                                     HelloWorldXml
                                     }
                             };
            var factory = new SparkViewFactory(settings)
                          {
                              ViewFolder = viewFolder
                          };

            var stream = new MemoryStream();
            var controllerContext = GetControllerContext(stream);

            var result = new PdfViewResult
                         {
                             ViewEngineCollection = new ViewEngineCollection(new[] { factory })
                         };
            result.ExecuteResult(controllerContext);

            Assert.That(stream.Length, Is.Not.EqualTo(0));
        }