Пример #1
0
        public void OneWayPropertyBindingDefaultValueValueType_SetSource_DestinationUpdated()
        {
            ///Arrange

            var view      = new DummyOneWayPropertyView();
            var viewModel = new DummyOneWayPropertyViewModel();

            view.BindingContext = new BindingContext();
            view.BindingContext.Add(view.Bind(v => v.ViewPropertyInt,
                                              vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt,
                                              null, 1234));
            view.ViewModel = viewModel;

            ///Act

            ///Assert

            Assert.AreEqual(1234, view.ViewPropertyInt);
        }
Пример #2
0
        public void Bind_NewMVVM_PropertyBindedFromVMtoView()
        {
            ///Arrange

            var view      = new DummyOneWayPropertyView();
            var viewModel = new DummyOneWayPropertyViewModel();

            view.BindingContext = new BindingContext();
            view.BindingContext.Add(view.Bind(v => v.ViewProperty,
                                              vm => ((DummyOneWayPropertyViewModel)vm).ViewModelProperty));
            view.ViewModel = viewModel;

            ///Act

            viewModel.ViewModelProperty = "Changed!";

            ///Assert

            Assert.AreEqual("Changed!", view.ViewProperty);
        }
Пример #3
0
        public void PropertyBindingWithFormatterCallbak_SetSource_DestinationUpdatedWithFormat()
        {
            ///Arrange

            var view      = new DummyOneWayPropertyView();
            var viewModel = new DummyOneWayPropertyViewModel();

            view.BindingContext = new BindingContext();
            view.BindingContext.Add(view.Bind(v => v.ViewProperty,
                                              vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt,
                                              new VASInt32Converter(), null, i => i + "FORMATTED!"));
            view.ViewModel = viewModel;

            ///Act

            viewModel.ViewModelPropertyInt = 12;

            ///Assert

            Assert.AreEqual("12FORMATTED!", view.ViewProperty);
        }
Пример #4
0
        public void OneWayPropertyBindingWithConverterFrom_SetSource_DestinationUpdated()
        {
            ///Arrange

            var view      = new DummyOneWayPropertyView();
            var viewModel = new DummyOneWayPropertyViewModel();

            view.BindingContext = new BindingContext();
            view.BindingContext.Add(view.Bind(v => v.ViewProperty,
                                              vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt,
                                              new VASInt32Converter()));
            view.ViewModel = viewModel;

            ///Act

            viewModel.ViewModelPropertyInt = 12;

            ///Assert

            Assert.AreEqual("12", view.ViewProperty);
        }
Пример #5
0
        public void OneWayPropertyBindingDefaultValueReferenceType_SetSource_DestinationUpdated()
        {
            ///Arrange

            var view      = new DummyOneWayPropertyView();
            var viewModel = new DummyOneWayPropertyViewModel();

            view.BindingContext = new BindingContext();
            view.BindingContext.Add(view.Bind(v => v.ViewComplexProperty,
                                              vm => ((DummyOneWayPropertyViewModel)vm).ViewModelComplexProperty,
                                              null, new ConfigDummy()
            {
                Lang = "MyLang"
            }));
            view.ViewModel = viewModel;

            ///Act

            ///Assert

            Assert.AreEqual("MyLang", view.ViewComplexProperty.Lang);
        }