public void CheckTwoFailuresAreReported() { var exception = Assert.Throws <ConfigurationException>(() => { using (var validator = new ConfigurationValidator(NoSettings)) { validator.Check(() => Property1); validator.Check(() => Property2); } }); Assert.That(exception.Message.Contains("Property1")); Assert.That(exception.Message.Contains("Property2")); }
public void CheckDoesNothingWhenSettingWithPrefixAvailable() { var setting = Setting("UK-BooleanProperty", "false"); using (var validator = new ConfigurationValidator(setting)) validator.Check("UK-", () => BooleanProperty); }
public void CheckDoesNothingWhenSettingWithPrefixAvailable() { var settings = Setting("UK-EnumProperty", "B"); using (var validator = new ConfigurationValidator(settings)) validator.Check("UK-", () => EnumProperty); }
public void CheckDoesNothingWhenSettingAvailable() { var settings = Setting("EnumProperty", "A"); using (var validator = new ConfigurationValidator(settings)) validator.Check(() => EnumProperty); }
public void CheckDoesNothingWhenSettingAvailable() { var settings = Setting("IntegerListProperty", "1,2"); using (var validator = new ConfigurationValidator(settings)) validator.Check(() => IntegerListProperty); }
public void CheckThrowsExceptionWhenSettingMissing() { var exception = Assert.Throws <ConfigurationException>(() => { using (var validator = new ConfigurationValidator(NoSettings)) validator.Check(() => BooleanProperty); }); Assert.AreEqual("The BooleanProperty setting is missing", exception.Message); }
public void CheckThrowsExceptionWhenSettingWithPrefixMissing() { var exception = Assert.Throws <ConfigurationException>(() => { using (var validator = new ConfigurationValidator(NoSettings)) validator.Check("UK-", () => EnumProperty); }); Assert.AreEqual("The UK-EnumProperty setting is missing", exception.Message); }
public void CheckThrowsExceptionWhenSettingUnParseable() { 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.Check(() => BooleanProperty); }); Assert.AreEqual($"The {PROPERTY_NAME} setting ('{UN_PARSEABLE}') can not be converted to a boolean", exception.Message); }
public void CheckThrowsExceptionWhenSettingWithPrefixUnParseable() { const string UN_PARSEABLE = "this is not parseable to an Enum"; const string PROPERTY_NAME = "EnumProperty"; const string PREFIX = "UK-"; var settings = Setting($"{PREFIX}{PROPERTY_NAME}", UN_PARSEABLE); var exception = Assert.Throws <ConfigurationException>(() => { using (var validator = new ConfigurationValidator(settings)) validator.Check(PREFIX, () => EnumProperty); }); Assert.AreEqual($"The {PREFIX}{PROPERTY_NAME} setting ('{UN_PARSEABLE}') can not be converted to a {nameof(Test)}", exception.Message); }