GetOption() public method

Retrieves the string representation of an option identified by a key.
is invalid.
public GetOption ( string key ) : string
key string The key of the option to retrieve.
return string
示例#1
0
 /// <inheritdoc/>
 public bool Equals(Config other)
 {
     if (other == null)
     {
         return(false);
     }
     return(_metaData.All(property => property.Value.Value == other.GetOption(property.Key)));
 }
示例#2
0
        public void TestGetSetValue()
        {
            var config = new Config();

            Assert.Throws <KeyNotFoundException>(() => config.SetOption("Test", "Test"));

            Assert.IsFalse(config.HelpWithTesting);
            Assert.AreEqual("False", config.GetOption("help_with_testing"));
            config.SetOption("help_with_testing", "True");
            Assert.Throws <FormatException>(() => config.SetOption("help_with_testing", "Test"));
            Assert.IsTrue(config.HelpWithTesting);
            Assert.AreEqual("True", config.GetOption("help_with_testing"));

            config.SetOption("freshness", "10");
            Assert.AreEqual(TimeSpan.FromSeconds(10), config.Freshness);
            Assert.AreEqual("10", config.GetOption("freshness"));
        }
示例#3
0
        public void TestGetSetValue()
        {
            var config = new Config();

            config.Invoking(x => x.SetOption("Test", "Test")).ShouldThrow <KeyNotFoundException>();

            config.HelpWithTesting.Should().BeFalse();
            config.GetOption("help_with_testing").Should().Be("False");
            config.SetOption("help_with_testing", "True");
            config.Invoking(x => x.SetOption("help_with_testing", "Test")).ShouldThrow <FormatException>();
            config.HelpWithTesting.Should().BeTrue();
            config.GetOption("help_with_testing").Should().Be("True");

            config.SetOption("freshness", "10");
            config.Freshness.Should().Be(TimeSpan.FromSeconds(10));
            config.GetOption("freshness").Should().Be("10");
        }
 /// <inheritdoc/>
 public bool Equals(Config other)
 => other != null &&
 _metaData.All(property => property.Value.Value == other.GetOption(property.Key));
 /// <inheritdoc/>
 public bool Equals(Config other)
 {
     if (other == null) return false;
     return _metaData.All(property => property.Value.Value == other.GetOption(property.Key));
 }
示例#6
0
        public void TestGetSetValue()
        {
            var config = new Config();
            Assert.Throws<KeyNotFoundException>(() => config.SetOption("Test", "Test"));

            Assert.IsFalse(config.HelpWithTesting);
            Assert.AreEqual("False", config.GetOption("help_with_testing"));
            config.SetOption("help_with_testing", "True");
            Assert.Throws<FormatException>(() => config.SetOption("help_with_testing", "Test"));
            Assert.IsTrue(config.HelpWithTesting);
            Assert.AreEqual("True", config.GetOption("help_with_testing"));

            config.SetOption("freshness", "10");
            Assert.AreEqual(TimeSpan.FromSeconds(10), config.Freshness);
            Assert.AreEqual("10", config.GetOption("freshness"));
        }
示例#7
0
        public void TestGetSetValue()
        {
            var config = new Config();
            config.Invoking(x => x.SetOption("Test", "Test")).ShouldThrow<KeyNotFoundException>();

            config.HelpWithTesting.Should().BeFalse();
            config.GetOption("help_with_testing").Should().Be("False");
            config.SetOption("help_with_testing", "True");
            config.Invoking(x => x.SetOption("help_with_testing", "Test")).ShouldThrow<FormatException>();
            config.HelpWithTesting.Should().BeTrue();
            config.GetOption("help_with_testing").Should().Be("True");

            config.SetOption("freshness", "10");
            config.Freshness.Should().Be(TimeSpan.FromSeconds(10));
            config.GetOption("freshness").Should().Be("10");
        }