Example #1
0
        public void TestConvertBackWithUnassignedConvertBackwardEventThrows()
        {
            var converter = new RelayValueConverter();

            converter.ConvertForward += (value, type, parameter, culture) => null;

            Assert.That(
                () => converter.ConvertBack(1, typeof(int), null, null),
                Throws.TypeOf <NotSupportedException>().With.Message.Contains(RelayValueConverter.ConvertBackwardName));
        }
Example #2
0
        public void TestConvertBackWithAssignedConvertForwardEventSucceeds()
        {
            var converter = new RelayValueConverter();

            converter.ConvertBackward += (value, type, parameter, culture) => int.Parse((string)value);

            Assert.That(
                () => converter.ConvertBack("42", null, null, null),
                Is.EqualTo(42));
        }
Example #3
0
        public void TestConvertWithAssignedConvertForwardEventSucceeds()
        {
            var converter = new RelayValueConverter();

            converter.ConvertForward += (value, type, parameter, culture) => value.ToString();

            Assert.That(
                () => converter.Convert(42, null, null, null),
                Is.EqualTo("42"));
        }