public void SetPropertyMethodShouldSetTheNewValue() { int value = 10; MockViewModel mockViewModel = new MockViewModel(); Assert.AreEqual(mockViewModel.MockProperty, 0); mockViewModel.MockProperty = value; Assert.AreEqual(mockViewModel.MockProperty, value); }
public void SetPropertyMethodShouldRaisePropertyRaised() { bool invoked = false; MockViewModel mockViewModel = new MockViewModel(); mockViewModel.PropertyChanged += (o, e) => { if (e.PropertyName.Equals("MockProperty")) invoked = true; }; mockViewModel.MockProperty = 10; Assert.IsTrue(invoked); }
public void OnPropertyChangedShouldExtractPropertyNameCorrectly() { bool invoked = false; MockViewModel mockViewModel = new MockViewModel(); mockViewModel.PropertyChanged += (o, e) => { if (e.PropertyName.Equals("MockProperty")) invoked = true; }; mockViewModel.InvokeOnPropertyChanged(); Assert.IsTrue(invoked); }
public void SetPropertyMethodShouldNotSetTheNewValue() { int value = 10; MockViewModel mockViewModel = new MockViewModel(); mockViewModel.MockProperty = 10; bool invoked = false; mockViewModel.PropertyChanged += (o, e) => { if (e.PropertyName.Equals("MockProperty")) invoked = true; }; mockViewModel.MockProperty = value; Assert.IsFalse(invoked); Assert.AreEqual(mockViewModel.MockProperty, value); }