public void LoadKeyValuePairsFromCommandLineArgumentsWithoutSwitchMappings() { var args = new string[] { "Key1=Value1", "--Key2=Value2", "/Key3=Value3", "--Key4", "Value4", "/Key5", "Value5" }; var cmdLineConfig = new CommandLineConfigurationSource(args); cmdLineConfig.Load(); Assert.Equal("Value1", cmdLineConfig.Get("Key1")); Assert.Equal("Value2", cmdLineConfig.Get("Key2")); Assert.Equal("Value3", cmdLineConfig.Get("Key3")); Assert.Equal("Value4", cmdLineConfig.Get("Key4")); Assert.Equal("Value5", cmdLineConfig.Get("Key5")); }
public void LoadKeyValuePairsFromCommandLineArgumentsWithSwitchMappings() { var args = new string[] { "-K1=Value1", "--Key2=Value2", "/Key3=Value3", "--Key4", "Value4", "/Key5", "Value5", "/Key6=Value6" }; var switchMappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "-K1", "LongKey1" }, { "--Key2", "SuperLongKey2" }, { "--Key6", "SuchALongKey6"} }; var cmdLineConfig = new CommandLineConfigurationSource(args, switchMappings); cmdLineConfig.Load(); Assert.Equal("Value1", cmdLineConfig.Get("LongKey1")); Assert.Equal("Value2", cmdLineConfig.Get("SuperLongKey2")); Assert.Equal("Value3", cmdLineConfig.Get("Key3")); Assert.Equal("Value4", cmdLineConfig.Get("Key4")); Assert.Equal("Value5", cmdLineConfig.Get("Key5")); Assert.Equal("Value6", cmdLineConfig.Get("SuchALongKey6")); }
public void OverrideValueWhenKeyIsDuplicated() { var args = new string[] { "/Key1=Value1", "--Key1=Value2" }; var cmdLineConfig = new CommandLineConfigurationSource(args); cmdLineConfig.Load(); Assert.Equal("Value2", cmdLineConfig.Get("Key1")); }