#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.Info(String.Format("Requested import type not found: {0}", parameters.ImportType)); 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(); } Tracing.Info("Import complete"); }
public void Execute(string[] arguments) { Tracing.Info("import - import posts from external source"); Settings.Parse(arguments); var path = String.IsNullOrWhiteSpace(SitePath) ? Directory.GetCurrentDirectory() : SitePath; if (!Importers.Any(e => String.Equals(e, ImportType, StringComparison.InvariantCultureIgnoreCase))) { Tracing.Info(String.Format("Requested import type not found: {0}", ImportType)); return; } if (string.Equals("wordpress", ImportType, StringComparison.InvariantCultureIgnoreCase)) { var wordpressImporter = new WordpressImport(fileSystem, SitePath, ImportPath); wordpressImporter.Import(); } Tracing.Info("Import complete"); }
public void Posts_Are_Imported() { var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { ImportFile, new MockFileData(ImportContent) } }); var wordpressImporter = new WordpressImport(fileSystem, BaseSite, ImportFile); wordpressImporter.Import(); Assert.True(fileSystem.File.Exists(BaseSite + "_posts\\2010-02-06-hello-world.md")); var postContent = fileSystem.File.ReadAllText(BaseSite + "_posts\\2010-02-06-hello-world.md"); var header = postContent.YamlHeader(); Assert.Equal("Hello world!", header["title"].ToString()); }
public WordpressImportTests() { publishedTimeStamp = new DateTimeOffset(2010, 02, 06, 11, 22, 38, TimeSpan.Zero); var datePublished = publishedTimeStamp.ToString("ddd, dd MMM yyyy hh:mm:ss zzzzz"); outputFileName = string.Format("{0}_posts\\{1}-hello-world.md", BaseSite, publishedTimeStamp.ToString("yyyy-MM-dd")); fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { ImportFile, new MockFileData(string.Format(ImportContent, datePublished)) } }); wordpressImporter = new WordpressImport(fileSystem, BaseSite, ImportFile); }