Exemple #1
0
        public void CanSave()
        {
            var config = new ConfigSource();

            config["name"] = "kishore";
            config["opensource", "projectname"] = "commonlibrary.net";
            config["opensource", "years"]       = 1;
            config["job", "title"]     = "developer";
            config["job", "skill"]     = 2;
            config["job", "pay"]       = 90000.52;
            config["job", "isManager"] = true;
            config["job", "startdate"] = DateTime.Today.Date;

            Assert.AreEqual(config.Sections.Count, 2);
            Assert.AreEqual(config.Sections[0], "opensource");
            Assert.AreEqual(config.Sections[1], "job");
            Assert.AreEqual(config.Count, 3);
            Assert.AreEqual(config.Get <string>("job", "title"), "developer");
            Assert.AreEqual(config.Get <int>("job", "skill"), 2);
            Assert.AreEqual(config.Get <double>("job", "pay"), 90000.52);
            Assert.AreEqual(config.Get <bool>("job", "isManager"), true);
            Assert.AreEqual(config.Get <DateTime>("job", "startdate"), DateTime.Today.Date);
            Assert.AreEqual(config.GetSection("job").Name, "job");
            Assert.AreEqual(config.GetSection("job").Count, 5);
        }