Exemple #1
0
        static void SimplyRun(Type packageType, Uri packageUri)
        {
            XcstViewPage package = CreatePackage(packageType);

            XcstEvaluator.Using((object)package)
            .CallInitialTemplate()
            .OutputTo(TextWriter.Null)
            .WithBaseUri(packageUri)
            .WithBaseOutputUri(packageUri)
            .Run();
        }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
            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);
                }
            }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public PageInitHttpHandler(XcstViewPage page)
     : base(page)
 {
 }