public void ConvertFrom_Text_ReturnExpectedConfigurationInflowModelType(string value, ConfigurationStabilityPointStructuresInflowModelType expectedResult) { // Setup var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter(); // Call object result = converter.ConvertFrom(value); // Assert Assert.AreEqual(expectedResult, result); }
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); }
/// <summary> /// Converts the given <paramref name="type"/> to a <see cref="string"/>. /// </summary> /// <param name="type">The <see cref="ConfigurationStabilityPointStructuresInflowModelType"/> to convert.</param> /// <returns>The converted <see cref="ConfigurationStabilityPointStructuresInflowModelType"/>.</returns> /// <exception cref="NotSupportedException">Thrown when <paramref name="type"/> is not supported.</exception> private static string ConvertToString(ConfigurationStabilityPointStructuresInflowModelType type) { switch (type) { case ConfigurationStabilityPointStructuresInflowModelType.LowSill: return(StabilityPointStructuresConfigurationSchemaIdentifiers.InflowModelLowSillStructure); case ConfigurationStabilityPointStructuresInflowModelType.FloodedCulvert: return(StabilityPointStructuresConfigurationSchemaIdentifiers.InflowModelFloodedCulvertStructure); default: throw new NotSupportedException(); } }
public void ConvertTo_InvalidConfigurationInflowModelType_ThrowInvalidEnumArgumentException(Type destinationType) { // Setup var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter(); const ConfigurationStabilityPointStructuresInflowModelType invalidValue = (ConfigurationStabilityPointStructuresInflowModelType)99999; // Call TestDelegate call = () => converter.ConvertTo(invalidValue, destinationType); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationStabilityPointStructuresInflowModelType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }
/// <summary> /// Converts the given <paramref name="type"/> to a <see cref="StabilityPointStructureInflowModelType"/>. /// </summary> /// <param name="type">The <see cref="ConfigurationStabilityPointStructuresInflowModelType"/> to convert.</param> /// <returns>The converted <see cref="ConfigurationStabilityPointStructuresInflowModelType"/>.</returns> /// <exception cref="NotSupportedException">Thrown when <paramref name="type"/> is not supported.</exception> private static StabilityPointStructureInflowModelType ConvertToStabilityPointStructureInflowModelType(ConfigurationStabilityPointStructuresInflowModelType type) { switch (type) { case ConfigurationStabilityPointStructuresInflowModelType.LowSill: return(StabilityPointStructureInflowModelType.LowSill); case ConfigurationStabilityPointStructuresInflowModelType.FloodedCulvert: return(StabilityPointStructureInflowModelType.FloodedCulvert); default: throw new NotSupportedException(); } }