public void Values()
        {
            var config = new ConfigSection(new DataTableSectionResolver(_dataTable, "First", "Second"));

            Assert.AreEqual("ValueA", config.AsString("A"));
            Assert.AreEqual("ValueB", config.AsString("B"));
            Assert.AreEqual(10, config.AsInt("C"));
            Assert.IsTrue(config.AsBoolean("D"));
            Assert.AreEqual(new DateTime(1983, 7, 30), config.AsDateTime("E"));
        }
Beispiel #2
0
        public void Values()
        {
            var config = new ConfigSection(new YamlSectionResolver(FileSample));

            Assert.AreEqual("MyName", config.AsString("Name"));
            Assert.AreEqual("ValueA", config.AsString("Section/A"));
            Assert.AreEqual("ValueB", config.AsString("Section/B"));
            Assert.AreEqual(new DateTime(1983, 7, 30), config.AsDateTime("Date"));
            Assert.AreEqual(10, config.AsInt("Number"));
            Assert.IsTrue(config.AsBoolean("Boolean"));

            CollectionAssert.AreEqual(new[] { "msedge", "excel" }, config.AsArray("Array"));
        }
Beispiel #3
0
        public void Values()
        {
            var config = new ConfigSection(new DictionarySectionResolver(_dic));

            Assert.AreEqual("ValueA", config.AsString("A"));
            Assert.AreEqual("ValueB", config.AsString("B"));
            Assert.AreEqual(10, config.AsInt("C"));
            Assert.IsTrue(config.AsBoolean("D"));
            Assert.AreEqual(new DateTime(1983, 7, 30), config.AsDateTime("E"));
            Assert.IsInstanceOfType(config["F"], typeof(ConfigSection));
            Assert.AreEqual(1, config.AsInt("F/A"));
            Assert.IsInstanceOfType(config["G"], typeof(Exception));
        }
Beispiel #4
0
 public void Overall()
 {
     Assert.AreEqual(10, _config.Count);
     Assert.IsTrue(_config.HasSection("sub-section"));
     Assert.IsTrue(_config.HasSection("sub-section/sub-section"));
     Assert.AreEqual(10, _config.AsInt("int"));
     Assert.AreEqual(10.10d, _config.AsDouble("double"));
     Assert.AreEqual(10.15m, _config.AsDecimal("decimal"));
     Assert.AreEqual(10.20f, _config.AsFloat("float"));
     Assert.AreEqual(20, _config.AsLong("long"));
     Assert.AreEqual(new DateTime(2021, 12, 11, 17, 23, 0), _config.AsDateTime("datetime"));
     Assert.IsTrue(_config.AsBoolean("boolean"));
     CollectionAssert.AreEqual(new[] { 1, 2, 3 }, _config.AsArray <int>("array"));
     CollectionAssert.AreEqual(new List <int> {
         1, 2, 3
     }, _config.AsList <int>("list"));
 }