예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void ParseCommonOptions_KmerFastaDoesntExist_DisplaysError(TemporaryDirectoryFixture tempDirectory)
        {
            // arrange
            Option <CommonOptions> commonOptionsParser = new CommonOptionsParser();
            var kmerFasta = tempDirectory.GetFileLocation("kmerv2.fa");
            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(), "--filter-bed", filterBed.ToString()
            };

            // act
            ParsingResult <CommonOptions> result = commonOptionsParser.Parse(stringInputArgument);

            // assert
            Assert.False(result.Success);
            Assert.Contains("kmerv2.fa", result.ErrorMessage);
            Assert.Contains("does not exist", result.ErrorMessage);
        }
예제 #6
0
        public void ParseMultiFileOption_WithMultipleFileArguments_ReturnsListOfFileLocations()
        {
            using (TemporaryDirectoryFixture tempDirectory = new TemporaryDirectoryFixture())
            {
                // 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]);
            }
        }
예제 #7
0
        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]);
        }
예제 #8
0
        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);
        }
예제 #9
0
        public void ParseRequiredExclusiveOption_WithNeitherOptionSpecified_ReturnsFailedParseResult(TemporaryDirectoryFixture tempDirectory)
        {
            FileOption option1 = FileOption.CreateRequired("file1 option", "file1");
            FileOption option2 = FileOption.CreateRequired("file2 option", "file2");
            // arrange
            ExclusiveFileOption multiFileOption = ExclusiveFileOption.CreateRequired(option1, option2);

            string[] args =
            {
            };

            // act
            var result = multiFileOption.Parse(args);

            // assert
            Assert.Contains("must be specified", result.ErrorMessage);
            Assert.False(result.Success);
        }