Beispiel #1
0
        public void When_Converted_Value_NotNull()
        {
            var target          = new MyControl();
            var viewModel       = new ViewModel();
            var converter       = new IdentityConverter();
            var targetNullValue = "this is the targetNullValue";

            target.DataContext = viewModel;
            target.SetBinding(
                MyControl.MyPropertyProperty,
                new Windows.UI.Xaml.Data.Binding(nameof(viewModel.NotNullValue))
            {
                Converter       = converter,
                TargetNullValue = targetNullValue,
            }
                );

            Assert.AreEqual(viewModel.NotNullValue, target.MyProperty);

            Assert.AreEqual(1, converter.ConvertHitCount);
        }
Beispiel #2
0
        public void When_Converted_Value_Null()
        {
            var target          = new MyControl();
            var viewModel       = new ViewModel();
            var converter       = new IdentityConverter();
            var targetNullValue = "this is the targetNullValue";

            target.DataContext = viewModel;
            target.SetBinding(
                MyControl.MyPropertyProperty,
                new Windows.UI.Xaml.Data.Binding(nameof(viewModel.NullValue))
            {
                Converter       = converter,
                TargetNullValue = targetNullValue,
            }
                );

            Assert.AreEqual(targetNullValue, target.MyProperty);

            Assert.AreEqual(
                2,
                converter.ConvertHitCount,
                "The converted is called first to check whether TargetNullValue should be called, then once more to convert TargetNullValue itself");
        }
Beispiel #3
0
 public void Exit()
 {
     _idConverter = null;
     _converter   = null;
 }
Beispiel #4
0
 public void Init()
 {
     _idConverter = IdentityConverter.Instance;
     _converter   = new DataConverter(_idConverter);
 }