Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }