public void ConvertBack_WithNonDoubleValueType_ReturnsNull(object value) { // Setup var converter = new AngleValueConverter(); // Call object result = converter.ConvertBack(value, typeof(Angle), null, null); // Assert Assert.That(result, Is.Null); }
public void ConvertBackIsDegreesFalse_WithAngleValueType_ReturnsExpectedResult(string value, double expectedResult) { // Setup var converter = new AngleValueConverter(); // Call object result = converter.ConvertBack(value, typeof(Angle), null, null); // Assert var convertedResult = (Angle)result; Assert.That(convertedResult.Radians, Is.EqualTo(expectedResult).Within(1e-5)); }
public void ConvertBack_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var converter = new AngleValueConverter(); 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)); }