예제 #1
0
        public void SnConfig_SectionName_Boundaries()
        {
            void Test()
            {
                var b1 = SnConfig.GetInt("feature1", "key2", 0, 400);

                Assert.AreEqual(456, b1);
                b1 = SnConfig.GetInt("feature1", "key2", 0, 500);
                Assert.AreEqual(500, b1);
                b1 = SnConfig.GetInt("feature1", "key2", 0, 0, 400);
                Assert.AreEqual(400, b1);

                var b2 = SnConfig.GetDouble("feature1", "key3", 0, 1);

                Assert.AreEqual(3.4, b2);
                b2 = SnConfig.GetDouble("feature1", "key3", 0, 4.5);
                Assert.AreEqual(4.5, b2);
                b2 = SnConfig.GetDouble("feature1", "key3", 0, 1, 2.3);
                Assert.AreEqual(2.3, b2);
            }

            using (new ConfigurationSwindler(CreateTestConfigurationForMemory()))
                Test();
            using (new ConfigurationSwindler(CreateTestConfigurationForJson()))
                Test();
            using (new ConfigurationSwindler(new SnLegacyConfiguration()))
                Test();
        }
예제 #2
0
        public void SnConfig_SectionName_Boundaries()
        {
            using (InMemoryConfigProvider.Create(TestAppSettings, TestConfigSections))
            {
                var b1 = SnConfig.GetInt("feature1", "key2", 0, 400);
                Assert.AreEqual(456, b1);
                b1 = SnConfig.GetInt("feature1", "key2", 0, 500);
                Assert.AreEqual(500, b1);
                b1 = SnConfig.GetInt("feature1", "key2", 0, 0, 400);
                Assert.AreEqual(400, b1);

                var b2 = SnConfig.GetDouble("feature1", "key3", 0, 1);
                Assert.AreEqual(3.4, b2);
                b2 = SnConfig.GetDouble("feature1", "key3", 0, 4.5);
                Assert.AreEqual(4.5, b2);
                b2 = SnConfig.GetDouble("feature1", "key3", 0, 1, 2.3);
                Assert.AreEqual(2.3, b2);
            }
        }