public void AddingTwoArgsWithSameNameShouldThrow() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("foo"); Should.Throw<InvalidOperationException>(() => builder.Arg("Foo")); }
public void ArgsShouldBeAccessibleInTheSameOrderTheyWereAdded() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("foo"); builder.Arg("bar"); builder.Definition.Args.First().Name.ShouldBe("foo"); builder.Definition.Args.Skip(1).First().Name.ShouldBe("bar"); }
public void ShouldParseMissingOptionalArg() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("name").IsOptional(); var settings = new CmdLineSettings(); var parser = new CmdLineParser(builder.Definition, settings); parser.Parse(new string[0]); }
public void ShouldParseArg() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("name"); var settings = new CmdLineSettings(); var parser = new CmdLineParser(builder.Definition, settings); var input = parser.Parse(new[] { "value" }); input.Args.GetSingle("name").ShouldBe("value"); }
public void ShouldParseParamsArg() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("name").IsParams(); var settings = new CmdLineSettings(); var parser = new CmdLineParser(builder.Definition, settings); var input = parser.Parse(new[] { "value1", "value2" }); input.Args.GetAll("name").ShouldBe(new[] { "value1", "value2" }); }
public void ShouldThrowIfRequiredArgIsntProvided() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("name"); var settings = new CmdLineSettings(); var parser = new CmdLineParser(builder.Definition, settings); Should.Throw<Exception>(() => parser.Parse(new string[0])); }
public void ConfiguredArgShouldHaveCorrectConfiguration() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("foo") .IsOptional() .IsParams() .Description("description") .DisplayName("displayName"); var definition = builder.Definition.Args.First(); definition.Name.ShouldBe("foo"); definition.IsOptional.ShouldBe(true); definition.IsParams.ShouldBe(true); definition.DisplayName.ShouldBe("displayName"); var writer = new TestWriter(); definition.DescriptionWriter(definition, writer, 0); writer.ToString().ShouldBe("description" + Environment.NewLine); }
public void ArgThatIsParamsShouldBeTheLastArg() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("foo").IsParams(); Should.Throw<InvalidOperationException>(() => builder.Arg("bar")); }
public void UnconfiguredArgShouldHaveCorrectDefaultConfiguration() { var builder = new CmdLineInputDefinitionBuilder(); builder.Arg("foo"); var definition = builder.Definition.Args.First(); definition.Name.ShouldBe("foo"); definition.IsOptional.ShouldBe(false); definition.IsParams.ShouldBe(false); definition.DescriptionWriter.ShouldBe(null); definition.DisplayName.ShouldBe(null); }