Esempio n. 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));
        }
Esempio n. 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"));
        }
Esempio n. 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"));
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 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));
        }