Exemple #1
0
        public void CommandListenToUIBusy_Test()
        {
            using (var vm1 = new SomeViewModel())
            {
                vm1.CommandExecuteWhenNotBusy.ListenToIsUIBusy(vm1, canExecuteWhenBusy: false);
                vm1.CommandExecuteWithUIBusyOnly.ListenToIsUIBusy(vm1, canExecuteWhenBusy:  true);

                vm1.IsUIBusy = true;
                Assert.IsFalse(vm1.CommandExecuteWhenNotBusy.CanExecute(null));
                Assert.IsTrue(vm1.CommandExecuteWithUIBusyOnly.CanExecute(null));

                vm1.IsUIBusy = false;


                Assert.IsTrue(vm1.CommandExecuteWhenNotBusy.CanExecute(null));
                Assert.IsFalse(vm1.CommandExecuteWithUIBusyOnly.CanExecute(null));
            }
        }
 public void CopyData_Test()
 {
     using (var vm1 = new SomeViewModel {
         Prop1 = "aaa", Prop2 = 1, Prop3 = 555.55, PropStringCol = new ObservableCollection <string> {
             "a", "b", "c"
         }
     })
         using (var vm2 = new SomeViewModel())
         {
             vm1.CopyTo(vm2);
             Assert.AreEqual(vm1.Prop1, vm2.Prop1);
             Assert.AreEqual(vm1.Prop2, vm2.Prop2);
             Assert.AreEqual(vm1.Prop3, vm2.Prop3);
             Assert.AreNotEqual(vm1.PropStringCol, vm2.PropStringCol);
             Assert.AreEqual(vm1.PropStringCol.Count, vm2.PropStringCol.Count);
             for (int i = 0; i < vm1.PropStringCol.Count; i++)
             {
                 Assert.AreEqual(vm1.PropStringCol[i], vm2.PropStringCol[i]);
             }
         }
 }