コード例 #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
ファイル: PdfViewResultTests.cs プロジェクト: dtabuenc/spark
        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
ファイル: PdfViewResultTests.cs プロジェクト: dtabuenc/spark
        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
ファイル: PdfViewResultTests.cs プロジェクト: dtabuenc/spark
        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));
        }