public void Posts_Are_Imported()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { ImportFile, new MockFileData(ImportContent) }
            });

            var wordpressImporter = new WordpressImportSql(fileSystem, BaseSite, ImportFile);
            wordpressImporter.Import();

            Assert.True(fileSystem.File.Exists(BaseSite + "_posts\\2010-09-28-about.md"));
            Assert.True(fileSystem.File.Exists(BaseSite + "_posts\\2010-12-07-recyclez-votre-vieux-pc-avec-jolicloud-1-1.md"));
            Assert.True(fileSystem.AllPaths.Count() == 3);
            var postContentAbout = fileSystem.File.ReadAllText(BaseSite + "_posts\\2010-09-28-about.md");
            var headerAbout = postContentAbout.YamlHeader();

            Assert.Equal("About", headerAbout["title"].ToString());

            var postContentJolicloud = fileSystem.File.ReadAllText(BaseSite + "_posts\\2010-12-07-recyclez-votre-vieux-pc-avec-jolicloud-1-1.md");
            var headerJolicloud = postContentJolicloud.YamlHeader();

            Assert.Equal("Recyclez votre vieux PC avec Jolicloud 1.1", headerJolicloud["title"].ToString());
            Assert.NotNull(headerJolicloud["tags"]);
            Assert.NotNull(headerJolicloud["categories"]);
        }
Exemplo n.º 2
0
#pragma warning restore 649

        public void Execute(IEnumerable<string> arguments)
        {
            Tracing.Info("import - import posts from external source");

            parameters.Parse(arguments);

            if (!Importers.Any(e => String.Equals(e, parameters.ImportType, StringComparison.InvariantCultureIgnoreCase)))
            {
                Tracing.Error(String.Format("Requested import type not found: {0}", parameters.ImportType));
                return;
            }
            if (String.IsNullOrEmpty(parameters.ImportPath))
            {
                Tracing.Error("Null or empty file name");
                return;
            }

            if (string.Equals("wordpress", parameters.ImportType, StringComparison.InvariantCultureIgnoreCase))
            {

                var wordpressImporter = new WordpressImport(fileSystem, parameters.Path, parameters.ImportPath);
                wordpressImporter.Import();
            }
            else if (string.Equals("blogger", parameters.ImportType, StringComparison.InvariantCultureIgnoreCase))
            {
                var bloggerImporter = new BloggerImport(fileSystem, parameters.Path, parameters.ImportPath);
                bloggerImporter.Import();
            }
            else if (string.Equals("wordpressSql", parameters.ImportType, StringComparison.InvariantCultureIgnoreCase))
            {
                var wordpressImporter = new WordpressImportSql(fileSystem, parameters.Path, parameters.ImportPath);
                wordpressImporter.Import();
            }

            Tracing.Info("Import complete");
        }