public void Constructor_With_Arguments_Throws_Exception_When_Checking_Invalid_Arguments() { var arguments = new[] { "--owiejfowijef29ijefpowiejfpo2ijf" }; var source = new CommandLineParserSource <object>(arguments); Assert.IsNotNull(source.Options); }
public void Constructor_With_Arguments_Populates_Options() { var arguments = new string[0]; var source = new CommandLineParserSource <object>(arguments); Assert.IsNotNull(source.Options); }
public void Constructor_With_Options_Populates_Options() { var options = new object(); var source = new CommandLineParserSource <object>(options); Assert.IsNotNull(source.Options); Assert.AreSame(options, source.Options); }
public void Constructor_With_Arguments_Does_Not_Throw_Exception_When_Checking_Invalid_Arguments_But_IgnoreUnknownArguments_Is_Set() { var arguments = new[] { "--owiejfowijef29ijefpowiejfpo2ijf" }; var parser = new Parser(p => { p.IgnoreUnknownArguments = true; }); var source = new CommandLineParserSource <object>(arguments, parser); Assert.IsNotNull(source.Options); }
public void Get_Returns_True_And_Null_When_Property_Exists_But_Is_Null() { const string name = nameof(TestOptions.StringProperty); var options = new TestOptions(); var source = new CommandLineParserSource <TestOptions>(options); string value; var result = source.Get(name, null, out value); Assert.IsTrue(result); Assert.IsNull(value); }
public void Get_Returns_False_And_Null_When_Property_Doesnt_Exist() { const string name = "property"; var options = new object(); var source = new CommandLineParserSource <object>(options); string value; var result = source.Get(name, null, out value); Assert.IsFalse(result); Assert.IsNull(value); }
public void Get_Returns_True_And_Value_When_Property_Exists() { const string name = nameof(TestOptions.StringProperty); const string expected = "expected"; var options = new TestOptions { StringProperty = expected }; var source = new CommandLineParserSource <TestOptions>(options); string value; var result = source.Get(name, null, out value); Assert.IsTrue(result); Assert.AreEqual(expected, value); }
public void Get_Converts_Non_String_Value_To_String() { const string name = nameof(TestOptions.NonStringProperty); const int expectedInt = 10; const string expectedString = "10"; var options = new TestOptions { NonStringProperty = expectedInt }; var source = new CommandLineParserSource <TestOptions>(options); string value; var result = source.Get(name, null, out value); Assert.IsTrue(result); Assert.AreEqual(expectedString, value); }