public void Constructor_ExpectedValues() { // Call var converter = new ConfigurationBreakWaterTypeConverter(); // Assert Assert.IsInstanceOf <TypeConverter>(converter); }
public void CanConvertTo_OtherThanStringOrBreakWaterType_ReturnFalse() { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call bool canConvertToString = converter.CanConvertTo(typeof(object)); // Assert Assert.IsFalse(canConvertToString); }
public void CanConvertTo_BreakWaterType_ReturnTrue() { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call bool canConvertToString = converter.CanConvertTo(typeof(BreakWaterType)); // Assert Assert.IsTrue(canConvertToString); }
public void ConvertFrom_InvalidText_ThrowNotSupportedException() { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call TestDelegate call = () => converter.ConvertFrom("A"); // Assert Assert.Throws <NotSupportedException>(call); }
public void CanConvertFrom_String_ReturnTrue() { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call bool canConvertFromString = converter.CanConvertFrom(typeof(string)); // Assert Assert.IsTrue(canConvertFromString); }
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 ConvertFrom_BreakWaterType_ReturnExpectedBreakWaterType(BreakWaterType value, ConfigurationBreakWaterType expectedResult) { // Setup var converter = new ConfigurationBreakWaterTypeConverter(); // Call object result = converter.ConvertFrom(value); // Assert Assert.AreEqual(expectedResult, result); }
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 ConvertFrom_InvalidClosingStructureInflowModelType_ThrowInvalidEnumArgumentException() { // Setup const int invalidValue = -1; var converter = new ConfigurationBreakWaterTypeConverter(); // Call TestDelegate call = () => converter.ConvertFrom((BreakWaterType)invalidValue); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(BreakWaterType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }
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); }