Exemple #1
0
            public async Task When_target_directory_is_sub_directory_of_source_then_markdown_files_in_target_dir_are_ignored()
            {
                const string markdown = @"
## C# null coalesce example
``` cs --source-file ./../project/Program.cs --region null_coalesce --project ./../project/some.csproj
```
";
                var          files    = PrepareFiles(
                    ("./project/some.csproj", CsprojContents),
                    ("./project/Program.cs", CompilingProgramWithRegionCs),
                    ("./documentation/details/doc.md", markdown),
                    ("./doc_output/details/doc.md", "result file of previous publish run, will be overridden when publishing docs and should be ignored as source")
                    );

                var targetDir = (DirectoryInfo)files.GetFullyQualifiedPath(new RelativeDirectoryPath("doc_output"));
                var target    = new InMemoryDirectoryAccessor(targetDir);

                var(publishOutput, resultCode) = await DoPublish(files, target);

                resultCode.Should().Be(0);
                publishOutput.OutputFiles.Count().Should().Be(1, "Expected existing file in doc_output to be ignored");
                var outputFilePath   = new FileInfo(publishOutput.OutputFiles.Single().Path);
                var expectedFilePath = target.GetFullyQualifiedPath(new RelativeFilePath("documentation/details/doc.md"));

                outputFilePath.FullName.Should().Be(expectedFilePath.FullName);
            }
        public async Task <DirectoryInfo> PrepareToolAndLocateAssetDirectory(PackageTool tool)
        {
            // e.g. C:\Users\abc\.trydotnet\packages\.store\PKGNAME\1.0.0\PKGNAME\1.0.0\tools\netcoreapp2.1\any\project

            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(tool.Name);

            var relativeToolDllPath = _directory.GetAllDirectoriesRecursively()
                                      .SingleOrDefault(d =>
            {
                if (d.Value.EndsWith($"/runner-{fileNameWithoutExtension}/"))
                {
                    return(true);
                }

                return(false);
            });

            if (relativeToolDllPath != null)
            {
                return((DirectoryInfo)_directory.GetFullyQualifiedPath(relativeToolDllPath));
            }

            return(null);
        }