Exemple #1
0
        public async Task <string> CompileMainPageNormalize(Site site)
        {
            var compiler = new DocifyEngineMock().Resolve <ICompiler>();

            var files = await compiler.Compile(site).ToListAsync();

            var res = files.First(f => f.Location.ToId() == "index.html").AsTextContent();

            res = Normalize(res);

            return(res);
        }
Exemple #2
0
        public async Task ImageAndImagePngTest()
        {
            var site = ComponentsTest.Instance.NewSite("{% seo %}", INCLUDE_PATH,
                                                       ComponentsTest.Instance.GetData <Metadata>("title: p1\r\ndescription: d1\r\nimage: img1.svg\r\nimage-png: img1.png"));

            site.MainPage.SubPages.Add(new PageMock("Page1", "{% seo %}", ComponentsTest.Instance.GetData <Metadata>("title: p1\r\nimage: img2.png")));

            var compiler = new DocifyEngineMock().Resolve <ICompiler>();
            var files    = await compiler.Compile(site).ToListAsync();

            var r1 = files.First(f => f.Location.ToId() == "index.html");
            var r2 = files.First(f => f.Location.ToId() == "Page1::index.html");

            Assert.AreEqual(Resources.seo5, r1.AsTextContent());
            Assert.AreEqual(Resources.seo6, r2.AsTextContent());
        }
Exemple #3
0
        public async Task SchemaTest()
        {
            var xmlFilePath = ComponentsTest.Instance.GetPath(@"feed\feed.xml");

            var site = ComponentsTest.Instance.NewSite("", INCLUDE_PATH);
            var p1   = new PageMock("Page1", "", ComponentsTest.Instance.GetData <Metadata>("title: p1\r\ndate: 2020-05-06"));
            var p2   = new PageMock("Page2", "", ComponentsTest.Instance.GetData <Metadata>("title: p2\r\ncategories:\r\n  - cat1\r\n  - cat2"));

            site.MainPage.SubPages.Add(p1);
            site.MainPage.SubPages.Add(p2);
            site.MainPage.Assets.Add(new AssetMock("feed.xml", System.IO.File.ReadAllBytes(xmlFilePath)));

            var compiler = new DocifyEngineMock().Resolve <ICompiler>();
            var files    = await compiler.Compile(site).ToListAsync();

            var feed = files.First(f => f.Location.FileName == "feed.xml");

            Assert.DoesNotThrow(() => SyndicationFeed.Load(XmlReader.Create(new System.IO.StringReader(feed.AsTextContent()))));
        }
Exemple #4
0
        public async Task BasicTest()
        {
            var xmlFilePath = ComponentsTest.Instance.GetPath(@"sitemap\sitemap.xml");

            var site = ComponentsTest.Instance.NewSite("", INCLUDE_PATH);
            var p1   = new PageMock("Page1", "", ComponentsTest.Instance.GetData <Metadata>("title: p1"));
            var p2   = new PageMock("Page2", "", ComponentsTest.Instance.GetData <Metadata>("title: p2"));

            site.MainPage.SubPages.Add(p1);
            site.MainPage.SubPages.Add(p2);
            site.MainPage.Assets.Add(new AssetMock("sitemap.xml", System.IO.File.ReadAllBytes(xmlFilePath)));

            var compiler = new DocifyEngineMock().Resolve <ICompiler>();
            var files    = await compiler.Compile(site).ToListAsync();

            var sitemap = files.First(f => f.Location.FileName == "sitemap.xml");

            Assert.AreEqual(Resources.sitemap1, ComponentsTest.Instance.Normalize(sitemap.AsTextContent()));
        }
Exemple #5
0
        public async Task PubDateTest()
        {
            var xmlFilePath = ComponentsTest.Instance.GetPath(@"feed\feed.xml");

            var site = ComponentsTest.Instance.NewSite("", INCLUDE_PATH);
            var p1   = new PageMock("Page1", "", ComponentsTest.Instance.GetData <Metadata>("title: p1\r\ndate: 2020-05-06"));

            site.MainPage.SubPages.Add(p1);
            site.MainPage.Assets.Add(new AssetMock("feed.xml", System.IO.File.ReadAllBytes(xmlFilePath)));

            var compiler = new DocifyEngineMock().Resolve <ICompiler>();
            var files    = await compiler.Compile(site).ToListAsync();

            var feed = files.First(f => f.Location.FileName == "feed.xml");

            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(feed.AsTextContent());

            var node = xmlDoc.SelectSingleNode("//channel/item[title='p1']/pubDate").InnerText;

            Assert.AreEqual("Wed, 06 May 2020 00:00:00 GMT", node);
        }