private void ValidateTokenizing(TestConfig testConfig) { _parser.Should().NotBeNull(); _parser !.Parse(testConfig.CommandLine) .Should() .BeTrue(); _parser.Collection.UnknownKeys.Count.Should().Be(testConfig.UnknownKeys); _parser.Collection.SpuriousValues.Count.Should().Be(testConfig.UnkeyedValues); foreach (var optConfig in testConfig.OptionConfigurations) { optConfig.Option ! .ValuesSatisfied .Should() .Be(optConfig.ValuesSatisfied); } }
public void SimpleLinuxParsing(string cmdLine, bool hasFlag, bool flag, string text) { var parser = Parser.GetLinuxDefault(null); parser.Should().NotBeNull(); var flagOption = parser !.Collection.Bind <SimpleObject, bool>(x => x.Switch, "x"); var textOption = parser.Collection.Bind <SimpleObject, string?>(x => x.Text, "y"); parser.Collection.FinishConfiguration(); parser !.Parse(cmdLine).Should().BeTrue(); if (hasFlag) { flagOption !.ValuesSatisfied.Should().BeTrue(); flagOption.GetValue(out var flagResult).Should().BeTrue(); flagResult.Should().Be(flag); } textOption !.ValuesSatisfied.Should().BeTrue(); textOption.GetValue(out var textResult).Should().BeTrue(); textResult.Should().Be(text); }