static void SimplyRun(Type packageType, Uri packageUri) { XcstViewPage package = CreatePackage(packageType); XcstEvaluator.Using((object)package) .CallInitialTemplate() .OutputTo(TextWriter.Null) .WithBaseUri(packageUri) .WithBaseOutputUri(packageUri) .Run(); }
protected override void RenderViewPage(XcstViewPage page, HttpContextBase context) { if (page is IPageInit pInit) { XcstEvaluator.Using(pInit) .CallFunction(p => p.Init()) .Run(); } else { base.RenderViewPage(page, context); } }
protected override void RenderViewPage(XcstViewPage page, HttpContext context) { context.Response.ContentType = "text/html"; if (page is IPageInit pInit) { XcstEvaluator.Using(pInit) .CallFunction(p => p.Init()) .Run(); } else { base.RenderViewPage(page, context); } }
static XcstViewPage CreatePackage(Type packageType) { XcstViewPage package = (XcstViewPage)Activator.CreateInstance(packageType); var httpContextMock = new Mock <HttpContextBase>(); httpContextMock.Setup(c => c.Items) .Returns(() => new System.Collections.Hashtable()); // Cookies and Headers used by a:antiforgery httpContextMock.Setup(c => c.Response.Cookies) .Returns(() => new HttpCookieCollection()); httpContextMock.Setup(c => c.Response.Headers) .Returns(() => new NameValueCollection()); package.ViewContext = new ViewContext(httpContextMock.Object); return(package); }
static bool OutputEqualsToExpected(Type packageType, Uri packageUri, bool printCode) { XcstViewPage package = CreatePackage(packageType); var expectedDoc = new XDocument(); var actualDoc = new XDocument(); XcstEvaluator evaluator = XcstEvaluator.Using((object)package); using (XmlWriter actualWriter = actualDoc.CreateWriter()) { evaluator.CallInitialTemplate() .OutputTo(actualWriter) .WithBaseUri(packageUri) .WithBaseOutputUri(packageUri) .Run(); } using (XmlWriter expectedWriter = expectedDoc.CreateWriter()) { evaluator.CallTemplate(_expectedName) .OutputTo(expectedWriter) .Run(); } XDocument normalizedExpected = XDocumentNormalizer.Normalize(expectedDoc); XDocument normalizedActual = XDocumentNormalizer.Normalize(actualDoc); bool equals = XNode.DeepEquals(normalizedExpected, normalizedActual); if (printCode || !equals) { Console.WriteLine("/*"); Console.WriteLine("<!-- expected -->"); Console.WriteLine(normalizedExpected.ToString()); Console.WriteLine(); Console.WriteLine("<!-- actual -->"); Console.WriteLine(normalizedActual.ToString()); Console.WriteLine("*/"); } return(equals); }
public PageInitHttpHandler(XcstViewPage page) : base(page) { }