Exemplo n.º 1
0
        public void TestGenericCastingOfInValidKeyReturnsNull()
        {
            bool result = true;
            int  myInt  = Section.TryParse <int>("keyXYZ", out result);

            Assert.IsFalse(result);
        }
Exemplo n.º 2
0
        public void TestGenericCastingOfValueToTypes()
        {
            ConfigLoader = new CustomConfigurations.Config("myCustomGroup/mysection");
            Section      = ConfigLoader.GetSection("client1");
            Assert.IsNotNull(Section);

            bool result = false;
            int  myInt  = Section.TryParse <int>("key5", out result);

            Assert.IsNotNull(myInt);
            Assert.AreEqual(7, myInt);
            Assert.IsTrue(result);

            result = false;
            float myfloat = Section.TryParse <float>("key6", out result);

            Assert.IsNotNull(myfloat);
            Assert.AreEqual(0.6f, myfloat);
            Assert.IsTrue(result);
        }
        public void TestGenericCastingOfValueToTypes()
        {
            ConfigLoader = new CustomConfigurations.Config("myCustomGroup/mysection");
            Section = ConfigLoader.GetSection("client1");
            Assert.IsNotNull(Section);

            bool result = false;
            int myInt = Section.TryParse<int>("key5", out result);
            Assert.IsNotNull(myInt);
            Assert.AreEqual(7, myInt);
            Assert.IsTrue(result);

            result = false;
            float myfloat = Section.TryParse<float>("key6", out result);
            Assert.IsNotNull(myfloat);
            Assert.AreEqual(0.6f, myfloat);
            Assert.IsTrue(result);
        }