Пример #1
0
        public void Get_Returns_Default_Value_On_Null_Key()
        {
            var appSettings = new AppSettingsParser(new FakeAppSettings());
            var value = appSettings.Get("NullableKey", "default");

            Assert.That(value, Is.EqualTo("default"));
        }
Пример #2
0
        public void Get_Throws_Exception_On_Bad_Value()
        {
            var appSettings = new AppSettingsParser(new FakeAppSettings());

            try
            {
                appSettings.Get<int>("BadIntegerKey", 1);
                Assert.Fail("Get did not throw a ConfigurationErrorsException");
            }
            catch (ConfigurationErrorsException ex)
            {
                Assert.That(ex.Message.Contains("BadIntegerKey"));
            }
        }
Пример #3
0
        public void Get_Casts_To_Specified_Type()
        {
            var appSettings = new AppSettingsParser(new FakeAppSettings());
            var value = appSettings.Get<int>("IntKey", 1);

            Assert.That(value, Is.EqualTo(42));
        }