public void GermlineWgsParse_WithRequiredArguments_ReturnsSuccessfulCallsetResult(string name, string description, StringWriter standardWriter, StringWriter errorWriter, TemporaryDirectoryFixture tempDirectory) { // arrange GermlineWgsModeParser germlineWgsModeParser = new GermlineWgsModeParser(name, description); MainParser parser = GetMainParser(germlineWgsModeParser); string[] args = { "-h" }; // act var result = parser.Parse(args, standardWriter, errorWriter); // assert Assert.True(result.Success); }
public void ParseCommonOptions_KmerFastaDoesntExist_DisplaysError(TemporaryDirectoryFixture tempDirectory) { // arrange Option<CommonOptions> commonOptionsParser = new CommonOptionsParser(); var kmerFasta = tempDirectory.GetFileLocation("kmer.fa"); var bAlleleVcf = tempDirectory.GetFileLocation("ballele.vcf").Touch(); var filterBed = tempDirectory.GetFileLocation("filter.bed").Touch(); var output = tempDirectory.CreateSubdirectory("output"); var genome = tempDirectory.CreateSubdirectory("WholeGenomeFasta"); string[] stringInputArgument = { "-r", kmerFasta.ToString(), "-o", output.ToString(), "-g", genome.ToString(), "--b-allele-vcf", bAlleleVcf.ToString(), "--filter-bed", filterBed.ToString(), "--sample-name", "SampleName" }; // act ParsingResult<CommonOptions> result = commonOptionsParser.Parse(stringInputArgument); // assert Assert.False(result.Success); Assert.Contains("kmer.fa", result.ErrorMessage); Assert.Contains("does not exist", result.ErrorMessage); }
public void ParseDictionaryOption_WithKeyOnlyArgument_ReturnsFailedResult(TemporaryDirectoryFixture tempDirectory) { // arrange DictionaryOption dictOption = DictionaryOption.Create("dictionary", "kvp"); string key = "key1"; string[] args = { "--kvp", key }; // act var result = dictOption.Parse(args); // assert Assert.False(result.Success); Assert.Contains("Error", result.ErrorMessage); Assert.Contains("format", result.ErrorMessage); }
public void ParseDictionaryOption_WithMultipleKeyValueArguments_ReturnsDictionary(TemporaryDirectoryFixture tempDirectory) { // arrange DictionaryOption dictOption = DictionaryOption.Create("dictionary", "kvp"); string key1 = "key1"; string value1 = "value1"; string key2 = "key2"; string value2 = "value2"; string[] args = { "--kvp", $"{key1}, {value1}","--kvp", $"{key2}, {value2}" }; // act var result = dictOption.Parse(args); // assert Assert.Equal("", result.ErrorMessage); Assert.True(result.Success); Assert.Equal(value1, result.Result[key1]); Assert.Equal(value2, result.Result[key2]); }
public void ParseMultiFileOption_WithMultipleFileArguments_ReturnsListOfFileLocations(TemporaryDirectoryFixture tempDirectory) { // arrange MultiValueOption<IFileLocation> multiFileOption = new MultiValueOption<IFileLocation>(FileOption.CreateRequired("multiple files", "file")); var file1 = tempDirectory.CreateFile("file1"); var file2 = tempDirectory.CreateFile("file2"); string[] args = { "--file", file1.ToString(), "--file", file2.ToString() }; // act var result = multiFileOption.Parse(args); // assert Assert.Equal("", result.ErrorMessage); Assert.True(result.Success); Assert.Equal(file1, result.Result[0]); Assert.Equal(file2, result.Result[1]); }
public void ParseCommonOptions_WithRequiredArguments_ReturnsSuccessfulResult(TemporaryDirectoryFixture tempDirectory) { // arrange Option<CommonOptions> commonOptionsParser = new CommonOptionsParser(); var kmerFasta = tempDirectory.CreateFile("kmer.fa"); var bAlleleVcf = tempDirectory.GetFileLocation("ballele.vcf").Touch(); var filterBed = tempDirectory.GetFileLocation("filter.bed").Touch(); var output = tempDirectory.CreateSubdirectory("output"); var genome = tempDirectory.CreateSubdirectory("WholeGenomeFasta"); string[] stringInputArgument = { "-r", kmerFasta.ToString(), "-o", output.ToString(), "-g", genome.ToString(), "--b-allele-vcf", bAlleleVcf.ToString(), "--filter-bed", filterBed.ToString(), "--sample-name", "SampleName" }; // act ParsingResult<CommonOptions> result = commonOptionsParser.Parse(stringInputArgument); // assert Assert.Equal("", result.ErrorMessage); Assert.True(result.Success); Assert.Equal(kmerFasta, result.Result.KmerFasta); Assert.Equal(output, result.Result.OutputDirectory); Assert.Equal(genome, result.Result.WholeGenomeFasta); }