예제 #1
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);
        }
예제 #2
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]);
        }