コード例 #1
0
        private (int exitCode, IList <string> lines) Format(
            bool skipWrite = false,
            bool check     = false,
            params string[] directoryOrFilePaths
            )
        {
            if (directoryOrFilePaths.Length == 0)
            {
                directoryOrFilePaths = new[] { GetRootPath() };
            }
            else
            {
                directoryOrFilePaths = directoryOrFilePaths.Select(
                    o => this.fileSystem.Path.Combine(GetRootPath(), o)
                    )
                                       .ToArray();
            }

            var fakeConsole = new TestConsole();
            var result      =
                CommandLineFormatter.Format(
                    new CommandLineOptions
            {
                DirectoryOrFilePaths = directoryOrFilePaths,
                SkipWrite            = skipWrite,
                Check = check
            },
                    this.fileSystem,
                    fakeConsole,
                    CancellationToken.None
                    ).Result;

            return(result, fakeConsole.Lines);
        }