Пример #1
0
        public void CreateStylesheets_TestChrysalis_CreatesCorrectStylesheet()
        {
            var chrysalis = ChrysalisMockFactory.CreateChrysalis();
            var generator = new StylesheetGenerator();
            var document  = generator.CreateStylesheets(chrysalis).First();

            Assert.IsType <XsltElement>(document.Root);
        }
Пример #2
0
        public void GetOutputElement_ContentTypeNone_ReturnsNull()
        {
            var generator     = new StylesheetGenerator();
            var testFieldData = ChrysalisMockFactory.MockIFieldData("TestFieldData", ContentType.None);

            var outputElement = generator.GetOutputElement(testFieldData);

            Assert.Null(outputElement);
        }
Пример #3
0
        public void GetOutputElement_InlineData_ReturnsExpectedXsltElement(ContentType fieldContentType, XsltElementType expectedXsltElementType)
        {
            var generator     = new StylesheetGenerator();
            var testFieldData = ChrysalisMockFactory.MockIFieldData("TestFieldData", fieldContentType);

            var outputElement = generator.GetOutputElement(testFieldData);

            Assert.Equal(expectedXsltElementType, outputElement.XsltElementType);
        }
Пример #4
0
        public void GetKeyElement_GroupWithoutKeyFields_ReturnsNull()
        {
            var generator = new StylesheetGenerator();
            var testGroup = ChrysalisMockFactory.MockISubGroup("TestTemplateMatch");

            testGroup.OutputData = ChrysalisMockFactory.MockIFieldData("TestOutputData");
            var keyElement = generator.GetKeyElement(testGroup);

            Assert.Null(keyElement);
        }
Пример #5
0
        public void GetKeyElement_GroupWithKeyFields_ReturnsXsltKeyElement()
        {
            var testKeyField = ChrysalisMockFactory.MockIField("TestKeyField");

            testKeyField.InputData = ChrysalisMockFactory.MockIFieldData("TestInputFieldData");

            var testGroup = ChrysalisMockFactory.MockISubGroup("TestTemplateMatch", testKeyField);

            testGroup.OutputData = ChrysalisMockFactory.MockIFieldData("TestOutputData");

            var generator  = new StylesheetGenerator();
            var keyElement = generator.GetKeyElement(testGroup);

            Assert.Equal(XsltElementType.Key, keyElement.XsltElementType);
        }
Пример #6
0
        public void CreateStylesheets_TestChrysalis_TransformsInputCorrectly()
        {
            var chrysalis = ChrysalisMockFactory.CreateChrysalis();
            var generator = new StylesheetGenerator();
            var document  = generator.CreateStylesheets(chrysalis).First();

            //WriteToFile(stylesheet);
            using (var documentReader = document.CreateReader())
                using (var inputReader = XmlReader.Create("TestCsvInput.xml"))
                    using (var stream = new MemoryStream())
                        using (var outputWriter = XmlWriter.Create(stream))
                        {
                            var transform = new XslCompiledTransform();

                            transform.Load(documentReader);
                            transform.Transform(inputReader, outputWriter);
                        }
        }
Пример #7
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            string theme  = context.Request.QueryString["theme"];
            string accent = context.Request.QueryString["accent"];

            if (String.IsNullOrEmpty(theme) || String.IsNullOrEmpty(accent))
            {
                throw new HttpException(400, "Bad Request");
            }
            ApplicationServices services = new ApplicationServices();
            string css = new StylesheetGenerator(theme, accent).ToString();

            context.Response.ContentType = "text/css";
            HttpCachePolicy cache = context.Response.Cache;

            cache.SetCacheability(HttpCacheability.Public);
            cache.SetOmitVaryStar(true);
            cache.SetExpires(System.DateTime.Now.AddDays(365));
            cache.SetValidUntilExpires(true);
            cache.SetLastModifiedFromFileDependencies();
            ApplicationServices.CompressOutput(context, css);
        }