Ejemplo n.º 1
0
        public void SubModelDependency_Test()
        {
            int counter = 0;
            var vm      = new ExpressionViewModelMock();

            vm.model.FirstValue       = 0;
            vm.model.PropertyChanged += (s, a) =>
            {
                if (a.PropertyName == nameof(vm.model.FirstValue))
                {
                    counter++;
                }
            };

            vm.PropertyChanged += (s, a) =>
            {
                if (a.PropertyName == nameof(vm.FirstValue))
                {
                    counter++;
                }
            };

            vm.model.FirstValue = 42;

            Assert.AreEqual(2, counter);
        }
Ejemplo n.º 2
0
        public void Constructor_Test()
        {
            var vm = new ExpressionViewModelMock();

            Assert.IsNotNull(vm);

            var vm1 = new ExpressionViewModelMock(new EventCommand());

            Assert.IsNotNull(vm1);
        }
Ejemplo n.º 3
0
        public void UpdatedCommandNotify_Test()
        {
            int counter = 0;
            var vm      = new ExpressionViewModelMock(new EventCommand());

            vm.CommandCanExecute = false;
            vm.model.FirstValue  = 0;

            vm.Command.CanExecuteChanged += (s, a) => counter++;

            vm.CommandCanExecute = true;
            vm.model.FirstValue  = 42;

            Assert.AreEqual(2, counter);
        }
Ejemplo n.º 4
0
        public void DirectDependencies_Test()
        {
            int counter = 0;
            var vm      = new ExpressionViewModelMock();

            vm.Name = "Initial";
            vm.Age  = 0;

            vm.PropertyChanged += (s, a) =>
            {
                if (a.PropertyName == nameof(vm.AgedName))
                {
                    counter++;
                }
            };

            vm.Name = "SomeName";
            vm.Age  = 42;

            Assert.AreEqual(2, counter);
        }