public void Arguments_HaveCorrectDescription_Returns_CorrectValue( string propertyName, string expectedDescription) { //Arrange var command = new CommandLineApplication(); var property = typeof(TestClass).GetProperty(propertyName); var descriptor = new ParameterDescriptor(property); //Act descriptor.AddCommandLineParameterTo(command); //Assert var actualOption = command.Arguments.First(); Assert.Equal(propertyName, actualOption.Name); Assert.Equal(expectedDescription, actualOption.Description); //Arrange command.Execute(new string[0] { }); //Assert Assert.Equal(null, descriptor.Value); //Is this right assumption to test? //Arrange command.Execute(new string[] { "PassedValue" }); //Assert Assert.Equal("PassedValue", descriptor.Value); }
public void Arguments_HaveCorrectDescription_Returns_CorrectValue( string propertyName, string expectedDescription) { //Arrange var command = new CommandLineApplication(); var property = typeof(TestClass).GetProperty(propertyName); var descriptor = new ParameterDescriptor(property); //Act descriptor.AddCommandLineParameterTo(command); //Assert var actualOption = command.Arguments.First(); Assert.Equal(propertyName, actualOption.Name); Assert.Equal(expectedDescription, actualOption.Description); //Arrange command.Execute(new string[0] { }); //Assert Assert.Equal(null, descriptor.Value); //Is this right assumption to test? //Arrange command.Execute(new string[] { "PassedValue" }); //Assert Assert.Equal("PassedValue", descriptor.Value); }
public void Options_UseCorrectName_Returns_CorrectValue( string propertyName, string expectedOptionTemplate, string expectedOptionDescription, string commandLineStringWithTheOption, object expectedValueWhenOptionIsPresent, object expectedValueWhenOptionIsNotPresent) { //Arrange var command = new CommandLineApplication(); var property = typeof(TestClass).GetProperty(propertyName); var descriptor = new ParameterDescriptor(property); var optionType = expectedValueWhenOptionIsPresent is bool ?CommandOptionType.NoValue : CommandOptionType.SingleValue; var expectedOption = new CommandOption(expectedOptionTemplate, optionType); //Act descriptor.AddCommandLineParameterTo(command); //Assert var actualOption = command.Options.First(); Assert.Equal(expectedOption.LongName, actualOption.LongName); Assert.Equal(expectedOption.ShortName, actualOption.ShortName); Assert.Equal(expectedOption.OptionType, actualOption.OptionType); Assert.Equal(expectedOptionDescription, actualOption.Description); //Arrange command.Execute(new string[0]); //Assert Assert.Equal(expectedValueWhenOptionIsNotPresent, descriptor.Value); //Arrange command.Execute(commandLineStringWithTheOption.Split(' ')); //Assert Assert.Equal(expectedValueWhenOptionIsPresent, descriptor.Value); }
public void Options_UseCorrectName_Returns_CorrectValue( string propertyName, string expectedOptionTemplate, string expectedOptionDescription, int expectedCommandOptionType, string commandLineStringWithTheOption, object expectedValueWhenOptionIsPresent, object expectedValueWhenOptionIsNotPresent) { //Arrange var command = new CommandLineApplication(); var property = typeof(TestClass).GetProperty(propertyName); var descriptor = new ParameterDescriptor(property); var expectedOption = new CommandOption(expectedOptionTemplate, (CommandOptionType)expectedCommandOptionType); //Act descriptor.AddCommandLineParameterTo(command); //Assert var actualOption = command.Options.First(); Assert.Equal(expectedOption.LongName, actualOption.LongName); Assert.Equal(expectedOption.ShortName, actualOption.ShortName); Assert.Equal(expectedOption.OptionType, actualOption.OptionType); Assert.Equal(expectedOptionDescription, actualOption.Description); //Arrange command.Execute(new string[0] { }); //Assert Assert.Equal(expectedValueWhenOptionIsNotPresent, descriptor.Value); //Arrange command.Execute(commandLineStringWithTheOption.Split(' ')); //Assert Assert.Equal(expectedValueWhenOptionIsPresent, descriptor.Value); }