Beispiel #1
0
        public void CheckWithDefaultThrowsExceptionWhenSettingUnParseable()
        {
            const string UN_PARSEABLE  = "this is not parseable to a bool";
            const string PROPERTY_NAME = "BooleanProperty";

            var setting = Setting(PROPERTY_NAME, UN_PARSEABLE);

            var exception = Assert.Throws <ConfigurationException>(() =>
            {
                using (var validator = new ConfigurationValidator(setting))
                    validator.CheckWithDefault(() => BooleanProperty);
            });

            Assert.AreEqual($"The {PROPERTY_NAME} setting ('{UN_PARSEABLE}') can not be converted to a boolean", exception.Message);
        }
Beispiel #2
0
 public void CheckWithDefaultDoesNothingWhenSettingMissing()
 {
     using (var validator = new ConfigurationValidator(NoSettings))
         validator.CheckWithDefault(() => BooleanProperty);
 }