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"));
        }
Beispiel #2
0
        public void CheckDoesNothingWhenSettingWithPrefixAvailable()
        {
            var setting = Setting("UK-BooleanProperty", "false");

            using (var validator = new ConfigurationValidator(setting))
                validator.Check("UK-", () => BooleanProperty);
        }
Beispiel #3
0
        public void CheckDoesNothingWhenSettingWithPrefixAvailable()
        {
            var settings = Setting("UK-EnumProperty", "B");

            using (var validator = new ConfigurationValidator(settings))
                validator.Check("UK-", () => EnumProperty);
        }
Beispiel #4
0
        public void CheckDoesNothingWhenSettingAvailable()
        {
            var settings = Setting("EnumProperty", "A");

            using (var validator = new ConfigurationValidator(settings))
                validator.Check(() => EnumProperty);
        }
Beispiel #5
0
        public void CheckDoesNothingWhenSettingAvailable()
        {
            var settings = Setting("IntegerListProperty", "1,2");

            using (var validator = new ConfigurationValidator(settings))
                validator.Check(() => IntegerListProperty);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
        }