public Parse ( string args, |
||
args | string | |
standardWriter | ||
errorWriter | ||
return | ParsingResult |
public static int Main(string[] args) { var modeParser = new MainParser(CanvasVersionInfo.VersionString, CanvasVersionInfo.CopyrightString, new GermlineWgsModeParser("Germline-WGS", "CNV calling of a germline sample from whole genome sequencing data"), new SomaticEnrichmentModeParser("Somatic-Enrichment", "CNV calling of a somatic sample from targeted sequencing data"), new TumorNormalWgsModeParser("Somatic-WGS", "CNV calling of a somatic sample from whole genome sequencing data"), new TumorNormalEnrichmentModeParser("Tumor-normal-enrichment", "CNV calling of a tumor/normal pair from targeted sequencing data")); var result = modeParser.Parse(args, Console.Out, Console.Error); if (!result.Success) return -1; return result.Result.Launch(); }
public void Parse_NoArguments_DisplaysError(string messageToDisplay, string name, string description, StringWriter standardWriter, StringWriter errorWriter) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser(name, description); MainParser parser = new MainParser(germlineWgsModeParser); string[] noArgs = { }; // act var result = parser.Parse(noArgs, standardWriter, errorWriter); string errorOutput = errorWriter.ToString(); // assert Assert.False(result.Success); Assert.Contains(messageToDisplay, errorOutput); Assert.Empty(standardWriter.ToString()); }
public void Parse_WithHelpArgument_ReturnsSuccecssAndDisplaysHelp(string messageToDisplay, string name, string description, StringWriter standardWriter, StringWriter errorWriter) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser(name, description); MainParser parser = new MainParser(germlineWgsModeParser); string[] args = { "-h" }; // act var result = parser.Parse(args, standardWriter, errorWriter); string standardOutput = standardWriter.ToString(); // assert Assert.True(result.Success); Assert.Contains(messageToDisplay, standardOutput); Assert.Empty(errorWriter.ToString()); }
public void GermlineWgsParse_WithRequiredArguments_ReturnsSuccessfulCallsetResult(string name, string description, StringWriter standardWriter, StringWriter errorWriter, TemporaryDirectoryFixture tempDirectory) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser(name, description); MainParser parser = new MainParser(germlineWgsModeParser); string[] args = { "-h" }; // act var result = parser.Parse(args, standardWriter, errorWriter); // assert Assert.True(result.Success); }
public void Parse_ModeWithVersion_ReturnsSuccecssAndDisplaysVersion(string messageToDisplay, string name, string description, StringWriter standardWriter, StringWriter errorWriter) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser("WGS", "Run Canvas from WGS data"); MainParser parser = new MainParser(germlineWgsModeParser); string[] modeArgs = { "WGS", "-v" }; // act var result = parser.Parse(modeArgs, standardWriter, errorWriter); string output = standardWriter.ToString(); // assert Assert.True(result.Success); string version = typeof(Program).Assembly.GetName().Version.ToString(); Assert.Contains(version, output); Assert.Empty(errorWriter.ToString()); }
public void Parse_ModeWithMissingRequiredArgument_DisplaysError(string messageToDisplay, string name, string description, StringWriter standardWriter, StringWriter errorWriter) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser("WGS", "Run Canvas from WGS data"); MainParser parser = new MainParser(germlineWgsModeParser); string[] modeArgs = { "WGS" }; // act parser.Parse(modeArgs, standardWriter, errorWriter); string errorOutput = errorWriter.ToString(); // assert Assert.Contains(messageToDisplay, errorOutput); Assert.Empty(standardWriter.ToString()); }