public static void Constructor_ExpectedValues() { // Call var converter = new NaNToEmptyValueConverter(); // Assert Assert.That(converter, Is.InstanceOf <IValueConverter>()); }
public void Convert_WithValidValueAndDutchCultureAndTargetTypeIsObject_ReturnsExpectedString(double value, string expectedValue) { // Setup var converter = new NaNToEmptyValueConverter(); // Call object result = converter.Convert(value, typeof(object), null, null); // Assert Assert.That(result, Is.EqualTo(expectedValue)); }
public void ConvertBack_WithNonDoubleValueType_ReturnsNull(object value) { // Setup var converter = new NaNToEmptyValueConverter(); // Call object result = converter.ConvertBack(value, typeof(double), null, null); // Assert Assert.That(result, Is.Null); }
public void ConvertBack_WithDoubleValueType_ReturnsExpectedResult(string value, double expectedResult) { // Setup var converter = new NaNToEmptyValueConverter(); // Call object result = converter.ConvertBack(value, typeof(double), null, null); // Assert Assert.That(result, Is.EqualTo(expectedResult).Within(1e-5)); }
public void Convert_WithUnsupportedValue_ThrowsNotSupportedException(object unsupportedValue) { // Setup var converter = new NaNToEmptyValueConverter(); // Call TestDelegate call = () => converter.Convert(unsupportedValue, typeof(string), null, null); // Assert string expectedMessage = $"Conversion from {unsupportedValue?.GetType().Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }
public void ConvertBack_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var converter = new NaNToEmptyValueConverter(); 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)); }
public void Convert_WithUnsupportedType_ThrowsNotSupportedException() { // Setup var random = new Random(21); double valueToConvert = random.NextDouble(); var converter = new NaNToEmptyValueConverter(); Type unsupportedType = typeof(int); // Call TestDelegate call = () => converter.Convert(valueToConvert, unsupportedType, null, null); // Assert string expectedMessage = $"Conversion to {unsupportedType.Name} is not supported."; Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>() .And.Message.EqualTo(expectedMessage)); }