Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }