public void TestBatchableViewModel_InBatchMode_ChangeProperty_NoPropertyChangedFired() { var vm = new TestBatchableViewModel(); var propertyName = String.Empty; var listOfPropertyNames = new List <string>(); var expectedName = nameof(vm.Name); vm.PropertyChanged += (sender, args) => { propertyName = args?.PropertyName; }; vm.PropertyChanged += (sender, args) => { listOfPropertyNames.Add(args?.PropertyName); }; vm.Begin_ViewModelUpdates(); vm.Name = "We are updating the name property and expecting it to fire the Property Changed on the name"; vm.End_ViewModelUpdates(); UnitTesting.Assert.AreEqual <string>(String.Empty, propertyName); UnitTesting.CollectionAssert.DoesNotContain(listOfPropertyNames, expectedName); UnitTesting.Assert.AreEqual(0, listOfPropertyNames.Count); }
public void TestBatchableViewModel_InBatchMode_ChangeModelProperty_NoPropertyChangedFired() { var listOfPropertyNames = new List <string>(); var vm = new TestBatchableViewModel(); vm.PropertyChanged += (sender, args) => { listOfPropertyNames.Add(args?.PropertyName); }; vm.Begin_ViewModelUpdates(); vm.SetBackingModel(new TestModel(name: "Test", id: 1)); vm.End_ViewModelUpdates(); var expectedListOfNames = new List <string>() { "Model", nameof(vm.Name), nameof(vm.ID) }; Assert.IsFalse(expectedListOfNames.Except(listOfPropertyNames).Count() == 0, $"Nothing should have fired...uh oh...: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}]."); Assert.IsTrue(listOfPropertyNames.Except(expectedListOfNames).Count() == 0, $"Nothing should have fired...uh oh...: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}]."); Assert.AreEqual(0, listOfPropertyNames.Count, "No names should have fired...uh oh..."); CollectionAssert.AreNotEqual(expectedListOfNames, listOfPropertyNames, $"The expected properties of the TestViewModel: expected:[{HelperMethods.GetStringFromCollection(expectedListOfNames)}], fired:[{HelperMethods.GetStringFromCollection(listOfPropertyNames)}]. They fired in an incorrect order..."); }
public void TestBatchableViewModel_NotInBatchMode_EndBatchMode_ErrorsSpecific() { var vm = new TestBatchableViewModel(); vm.End_ViewModelUpdates(); }