public void Get_Casts_To_Specified_Type() { var appSettings = new AppSettingsBase(new FakeAppSettings()); var value = appSettings.Get<int>("IntKey", 1); Assert.That(value, Is.EqualTo(42)); }
public void Get_Returns_Default_Value_On_Null_Key() { var appSettings = new AppSettingsBase(new FakeAppSettings()); var value = appSettings.Get("NullableKey", "default"); Assert.That(value, Is.EqualTo("default")); }
public void Get_Throws_Exception_On_Bad_Value() { var appSettings = new AppSettingsBase(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")); } }