public void ShouldSetCorrentEventArgsOnChanged() { var foo = new Foo(); foo.PropertyChanged += (sender, e) => Assert.AreEqual("Name", e.PropertyName); NotifiableProperty.Set(foo, x => x.Name, "new name"); }
public void ShouldSetCorrentEventSenderOnChanged() { var foo = new Foo(); foo.PropertyChanged += (sender, e) => Assert.AreSame(foo, sender); NotifiableProperty.Set(foo, x => x.Name, "new name"); }
public void ShouldStoreValueForProperty() { var foo = new Foo(); NotifiableProperty.Set(foo, x => x.Name, "new name"); var value = NotifiableProperty.Get(foo, x => x.Name); Assert.AreEqual("new name", value); }
public void ShouldRaisePropertyChangingEvent() { var mock = this.Mocked <IDisposable>(); var foo = new Foo(); foo.PropertyChanging += (sender, e) => mock.Dispose(); NotifiableProperty.Set(foo, x => x.Name, "new name"); Mock.Get(mock).Verify(d => d.Dispose(), Times.Once()); }
public void ShouldDistinguishDifferentTargets() { var foo1 = new Foo(); var foo2 = new Foo(); NotifiableProperty.Set(foo1, x => x.Name, "new name"); NotifiableProperty.Set(foo2, x => x.Name, "old name"); var value1 = NotifiableProperty.Get(foo1, x => x.Name); var value2 = NotifiableProperty.Get(foo2, x => x.Name); Assert.AreEqual("new name", value1); Assert.AreEqual("old name", value2); }
public void ShouldRaiseEventsInCorrectOrder() { var callstack = new List <string>(); var foo = new Foo(); foo.PropertyChanging += (sender, e) => callstack.Add("Changing"); foo.PropertyChanged += (sender, e) => callstack.Add("Changed"); NotifiableProperty.Set(foo, x => x.Name, "new name"); Assert.AreElementsSame( new[] { "Changing", "Changed" }, callstack ); }