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