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); }
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 ParseExclusiveOption_WithOnlyTwoOption_ReturnsFailedParseResult(TemporaryDirectoryFixture tempDirectory) { FileOption option1 = FileOption.CreateRequired("file1 option", "file1"); FileOption option2 = FileOption.CreateRequired("file2 option", "file2"); // arrange ExclusiveFileOption multiFileOption = ExclusiveFileOption.CreateRequired(option1, option2); var file1 = tempDirectory.CreateFile("file1"); string[] args = { "--file1", file1.ToString(), "--file2", file1.ToString() }; // act var result = multiFileOption.Parse(args); // assert Assert.Contains("not both", result.ErrorMessage); Assert.False(result.Success); }
public void ParseExclusiveOption_WithOnlyOneOption_ReturnsOneValue(TemporaryDirectoryFixture tempDirectory) { FileOption option1 = FileOption.CreateRequired("file1 option", "file1"); FileOption option2 = FileOption.CreateRequired("file2 option", "file2"); // arrange ExclusiveFileOption multiFileOption = ExclusiveFileOption.CreateRequired(option1, option2); var file1 = tempDirectory.CreateFile("file1"); string[] args = { "--file1", file1.ToString() }; // act var result = multiFileOption.Parse(args); // assert Assert.Equal("", result.ErrorMessage); Assert.True(result.Success); Assert.Equal(file1, result.Result.Result); Assert.Equal(option1, result.Result.MatchedOption); }