public void Constructor_ExpectedValues()
        {
            // Call
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Assert
            Assert.IsInstanceOf <TypeConverter>(converter);
        }
        public void CanConvertTo_OtherTypeThanStringOrStabilityPointStructureInflowModelType_ReturnFalse()
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            bool canConvertToNonString = converter.CanConvertTo(typeof(object));

            // Assert
            Assert.IsFalse(canConvertToNonString);
        }
        public void CanConvertTo_StabilityPointStructureInflowModelType_ReturnTrue()
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            bool canConvertToString = converter.CanConvertTo(typeof(StabilityPointStructureInflowModelType));

            // Assert
            Assert.IsTrue(canConvertToString);
        }
        public void ConvertFrom_InvalidType_ThrowNotSupportedException()
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertFrom(new object());

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
        public void ConvertTo_ForAllEnumValues_ReturnExpectedText(ConfigurationStabilityPointStructuresInflowModelType value,
                                                                  string expectedText)
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            object result = converter.ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(string));

            // Assert
            Assert.AreEqual(expectedText, result);
        }
        public void ConvertFrom_StabilityPointStructureInflowModelType_ReturnExpectedConfigurationInflowModelType(StabilityPointStructureInflowModelType value,
                                                                                                                  ConfigurationStabilityPointStructuresInflowModelType expectedResult)
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            object result = converter.ConvertFrom(value);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
        public void ConvertTo_InvalidType_ThrowNotSupportedException()
        {
            // Setup
            var random       = new Random(21);
            var invalidValue = random.NextEnumValue <ConfigurationStabilityPointStructuresInflowModelType>();
            var converter    = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

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

            // Assert
            Assert.Throws <NotSupportedException>(call);
        }
        /// <summary>
        /// Writes the <paramref name="inflowModelType"/> in XML format to file.
        /// </summary>
        /// <param name="writer">The writer to use for writing.</param>
        /// <param name="inflowModelType">The inflow model type to write.</param>
        /// <exception cref="InvalidOperationException">Thrown when the <paramref name="writer"/>
        /// is closed.</exception>
        /// <exception cref="NotSupportedException">Thrown when the conversion of
        /// <paramref name="inflowModelType"/> cannot be performed.</exception>
        private static void WriteConfigurationInflowModelTypeWhenAvailable(XmlWriter writer,
                                                                           ConfigurationStabilityPointStructuresInflowModelType?inflowModelType)
        {
            if (!inflowModelType.HasValue)
            {
                return;
            }

            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            writer.WriteElementString(StabilityPointStructuresConfigurationSchemaIdentifiers.InflowModelTypeElement,
                                      converter.ConvertToInvariantString(inflowModelType.Value));
        }
        public void ConvertFrom_InvalidText_ThrowNotSupportedException()
        {
            // Setup
            var          converter    = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();
            const string invalidValue = "some text";

            // Call
            TestDelegate call = () => converter.ConvertFrom(invalidValue);

            // Assert
            string message = Assert.Throws <NotSupportedException>(call).Message;

            Assert.AreEqual($"Value '{invalidValue}' is not supported.", message);
        }
        public void ConvertFrom_InvalidStabilityPointStructureInflowModelType_ThrowInvalidEnumArgumentException()
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();
            const StabilityPointStructureInflowModelType invalidValue = (StabilityPointStructureInflowModelType)983;

            // Call
            TestDelegate call = () => converter.ConvertFrom(invalidValue);

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

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