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 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); }
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); }