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