public void TestAzureMarkdownMigrationRewriters_AzureVideoLinkNoMapping() { var azureVideoInfoMapping = new Dictionary <string, AzureVideoInfo> { { "fake-azure-ad--introduction-to-dynamic-memberships-for-groups", new AzureVideoInfo { Id = "fake-azure-ad--introduction-to-dynamic-memberships-for-groups", Link = "https://channel9.msdn.com/Series/Azure-Active-Directory-Videos-Demos/Azure-AD--Introduction-to-Dynamic-Memberships-for-Groups/player/" } } }; var source = @"> [AZURE.VIDEO azure-ad--introduction-to-dynamic-memberships-for-groups]"; var expected = @"> [!VIDEO azure-ad--introduction-to-dynamic-memberships-for-groups] > > "; var result = AzureMigrationMarked.Markup(source, "sourceFile.md", azureVideoInfoMapping: azureVideoInfoMapping); Assert.Equal(expected.Replace("\r\n", "\n"), result); }
public void TestAzureMarkdownMigrationRewriters_AzureProperties_NoSiteIdentifier() { var source = @"<properties pageTitle=""Azure Container Service Introduction | Microsoft Azure Storage "" description=""Azure Container Service (ACS) provides a way to simplify the creation, configuration, and management of a cluster of virtual machines that are preconfigured to run containerized applications."" services=""virtual-machines"" documentationCenter="""" authors=""rgardler; fenxu"" manager=""nepeters"" editor="""" tags=""acs, azure-container-service"" keywords=""Docker, Containers, Micro-services, Mesos, Azure""/> <tags ms.service=""virtual-machines"" ms.devlang=""na"" ms.topic=""home-page"" ms.tgt_pltfrm=""na"" ms.workload=""na"" ms.date=""12/02/2015"" ms.author=""rogardle""/> # Azure Container Service Introduction "; var expected = @"--- title: Azure Container Service Introduction | Microsoft Docs description: Azure Container Service (ACS) provides a way to simplify the creation, configuration, and management of a cluster of virtual machines that are preconfigured to run containerized applications. services: virtual-machines documentationcenter: '' author: rgardler manager: nepeters editor: '' tags: acs, azure-container-service keywords: Docker, Containers, Micro-services, Mesos, Azure ms.service: virtual-machines ms.devlang: na ms.topic: home-page ms.tgt_pltfrm: na ms.workload: na ms.date: 12/02/2015 ms.author: rogardle --- # Azure Container Service Introduction "; var result = AzureMigrationMarked.Markup(source, "azure_file.md"); Assert.Equal(expected.Replace("\r\n", "\n"), result); }
private int Rewrite() { var exitCode = 0; var sourceDirInfo = new DirectoryInfo(_srcDirectory); var fileInfos = sourceDirInfo.GetFiles("*.md", SearchOption.AllDirectories); Console.WriteLine("Start transform dir '{0}' to dest dir '{1}' at {2}", _srcDirectory, _destDirectory, DateTime.UtcNow); Parallel.ForEach( fileInfos, new ParallelOptions() { MaxDegreeOfParallelism = 8 }, fileInfo => { var relativePathToSourceFolder = fileInfo.FullName.Substring(_srcDirectory.Length + 1); try { if (IsIgnoreFile(relativePathToSourceFolder, _isMigration)) { return; } var outputPath = Path.Combine(_destDirectory, relativePathToSourceFolder); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); if (string.Equals(fileInfo.Extension, MarkdownExtension, StringComparison.OrdinalIgnoreCase)) { var source = File.ReadAllText(fileInfo.FullName); string result; if (_isMigration) { result = AzureMigrationMarked.Markup( source, fileInfo.FullName, _azureFileInformationCollection.AzureMarkdownFileInfoMapping, _azureFileInformationCollection.AzureResourceFileInfoMapping, _azureFileInformationCollection.AzureIncludeMarkdownFileInfoMapping, _azureFileInformationCollection.AzureIncludeResourceFileInfoMapping, _azureFileInformationCollection.AzureVideoInfoMapping); } else { result = AzureMarked.Markup( source, fileInfo.FullName, _azureFileInformationCollection.AzureMarkdownFileInfoMapping, _azureFileInformationCollection.AzureVideoInfoMapping, _azureFileInformationCollection.AzureResourceFileInfoMapping); } File.WriteAllText(outputPath, result); } else { //Console.WriteLine("Copy file {0} to output path {1}", fileInfo.FullName, outputPath); //File.Copy(fileInfo.FullName, outputPath, true); } } catch (Exception e) { exitCode = 1; Console.Write($"System Error: Processing File: { relativePathToSourceFolder }. Error: Migration failed. Exception: {e}."); } }); Console.WriteLine("End transform dir '{0}' to dest dir '{1}' at {2}", _srcDirectory, _destDirectory, DateTime.UtcNow); return(exitCode); }