public void AssignValueThrowsIfPartialEnumValueIsAmbigious() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("TestEnum"); // Act and Assert ExceptionAssert.Throws <CommandLineException>(() => CommandLineParser.AssignValue(cmd, property, "TestEnum", "d"), "Ambiguous option 'd'. Possible values: Diagnostic Detailed."); }
public void AssignValueSetsEnumProperty(string value, TestEnum expectedValue) { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("TestEnum"); // Act CommandLineParser.AssignValue(cmd, property, "TestEnum", value); // Assert Assert.Equal(expectedValue, cmd.TestEnum); }
public void AssignValueAddsToCollection() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("DictionaryProperty"); var value = "MyKey=MyTestValue"; // Act CommandLineParser.AssignValue(cmd, property, "DictionaryProperty", value); // Assert Assert.Equal("MyTestValue", cmd.DictionaryProperty["MyKey"]); }
public void AssignValueAssignsPrimitiveValues() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("PrimitiveProperty"); var value = "Qux"; // Act CommandLineParser.AssignValue(cmd, property, "PrimitiveProperty", value); // Assert Assert.Equal("Qux", cmd.PrimitiveProperty); }
public void AssignValueThrowsIfPartialEnumValueIsAmbigious() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("TestEnum"); // Act and Assert ExceptionAssert.Throws<CommandLineException>(() => CommandLineParser.AssignValue(cmd, property, "TestEnum", "d"), "Ambiguous option 'd'. Possible values: Diagnostic Detailed."); }
public void AssignValueSetsEnumProperty(string value, TestEnum expectedValue) { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("TestEnum"); // Act CommandLineParser.AssignValue(cmd, property, "TestEnum", value); // Assert Assert.Equal(expectedValue, cmd.TestEnum); }
public void AssignValueAddsToCollection() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("DictionaryProperty"); var value = "MyKey=MyTestValue"; // Act CommandLineParser.AssignValue(cmd, property, "DictionaryProperty", value); // Assert Assert.Equal("MyTestValue", cmd.DictionaryProperty["MyKey"]); }
public void AssignValueAssignsPrimitiveValues() { // Arrange var cmd = new AssignValueType(); var property = cmd.GetType().GetProperty("PrimitiveProperty"); var value = "Qux"; // Act CommandLineParser.AssignValue(cmd, property, "PrimitiveProperty", value); // Assert Assert.Equal("Qux", cmd.PrimitiveProperty); }