Exemplo n.º 1
0
        public void Parse_FileName_Items()
        {
            var filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Infrastructure", "IO", "sample-url-file.txt");
            var actual   = UrlFileParser.Parse(filename);
            var items    = actual.Items.ToArray();

            Assert.AreEqual("/Users/giacomelli/Projects/jogosdaqui.github.io-jekyll/src", actual.JekyllRootFolder);
            Assert.AreEqual(3, items.Length);

            var item = items[0];

            Assert.AreEqual("http://www.monsterbed.com.br/games/trilha-ecologica/", item.Url);
            Assert.AreEqual("autor1", item.Config.Author);
            Assert.AreEqual(new DateTime(2018, 11, 28), item.Config.Date);

            item = items[1];
            Assert.AreEqual("http://www.monsterbed.com.br/games/isolados-a-fuga/", item.Url);
            Assert.AreEqual("autor2", item.Config.Author);
            Assert.AreEqual(new DateTime(2018, 11, 29), item.Config.Date);

            item = items[2];
            Assert.AreEqual("http://www.monsterbed.com.br/games/laco-macanudo-gaucho/", item.Url);
            Assert.AreEqual("autor3", item.Config.Author);
            Assert.AreEqual(new DateTime(2018, 11, 30), item.Config.Date);
        }
Exemplo n.º 2
0
        private async Task RunWithUrlFile(string file)
        {
            var urlFile = UrlFileParser.Parse(file);

            Logger.Debug($"Pasta raíz do Jekyll: {urlFile.JekyllRootFolder}");

            var postService = new PostService(urlFile.JekyllRootFolder);

            Logger.Info($"Items: {urlFile.Items.Count()}");

            foreach (var item in urlFile.Items)
            {
                await postService.WritePostAsync(item.Url, item.Config);
            }
        }