Esempio n. 1
0
        public void ConvertTo_InvalidDestinationType_ThrowsNotSupportedException()
        {
            // Setup
            var random    = new Random(21);
            var converter = new ConfigurationZoningBoundariesDeterminationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertTo(random.NextEnumValue <ConfigurationZoningBoundariesDeterminationType>(), typeof(object));

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
Esempio n. 2
0
        public void ConvertTo_VariousCases_ReturnExpectedResult(ConfigurationZoningBoundariesDeterminationType value,
                                                                object expectedResult)
        {
            // Setup
            var  converter     = new ConfigurationZoningBoundariesDeterminationTypeConverter();
            Type convertToType = expectedResult.GetType();

            // Call
            object result = converter.ConvertTo(value, convertToType);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 3
0
        public void ConvertTo_InvalidConfigurationZoningBoundariesDeterminationType_ThrowsInvalidEnumArgumentException(Type convertToType)
        {
            // Setup
            const ConfigurationZoningBoundariesDeterminationType invalidValue = (ConfigurationZoningBoundariesDeterminationType)9999;
            var converter = new ConfigurationZoningBoundariesDeterminationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertTo(invalidValue, convertToType);

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationZoningBoundariesDeterminationType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }