public void ConvertTo_InvalidDestinationType_ThrowsNotSupportedException() { // Setup var random = new Random(21); var converter = new ConfigurationBreakWaterTypeConverter(); // Call TestDelegate call = () => converter.ConvertTo(random.NextEnumValue <ConfigurationBreakWaterType>(), typeof(object)); // Assert Assert.Throws <NotSupportedException>(call); }
public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value, string expectedResult) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call object result = converter.ConvertTo(value, typeof(string)); // Assert Assert.AreEqual(expectedResult, result); }
public void ConvertTo_InvalidBreakWaterType_ThrowInvalidEnumArgumentException(Type destinationType) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); const ConfigurationBreakWaterType invalidValue = (ConfigurationBreakWaterType)99999999; // Call TestDelegate call = () => converter.ConvertTo(invalidValue, destinationType); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(ConfigurationBreakWaterType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }