public void ConvertBack_WithNonIntegerValueType_ReturnsNull(object value) { // Setup var converter = new IntegerValueConverter(); // Call object result = converter.ConvertBack(value, typeof(int), null, null); // Assert Assert.That(result, Is.Null); }
public void ConvertBack_WithIntegerValueType_ReturnsExpectedResult(string value, int expectedResult) { // Setup var converter = new IntegerValueConverter(); // Call object result = converter.ConvertBack(value, typeof(int), null, null); // Assert Assert.That(result, Is.EqualTo(expectedResult)); }
public void ConvertBack_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var converter = new IntegerValueConverter(); Type unsupportedType = typeof(object); // Call TestDelegate call = () => converter.ConvertBack("1", unsupportedType, null, null); // Assert string expectedMessage = $"Conversion to {unsupportedType.Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }