Пример #1
0
        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);
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }