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