public void BindWeakThrowsIfTargetIsCompilerGenerated() { var c1 = new NotifyingClass(); string newVal = null; Assert.Throws <InvalidOperationException>(() => c1.BindWeak(x => x.Foo, (o, e) => newVal = e.NewValue)); }
public void BindWeakPassesSender() { var c1 = new NotifyingClass(); c1.BindWeak(x => x.Foo, (o, e) => this.sender = o); c1.Foo = "foo"; Assert.AreEqual(c1, this.sender); }
public void WeakBindingBinds() { var c1 = new NotifyingClass(); c1.BindWeak(x => x.Foo, (o, e) => this.newVal = e.NewValue); c1.Foo = "bar"; Assert.AreEqual("bar", this.newVal); }
public void WeakBindingIgnoresOtherProperties() { var c1 = new NotifyingClass(); c1.BindWeak(x => x.Bar, (o, e) => this.newVal = e.NewValue); c1.Foo = "bar"; Assert.IsNull(this.newVal); }
public void WeakBindingUnbinds() { var c1 = new NotifyingClass(); var binding = c1.BindWeak(x => x.Bar, (o, e) => this.newVal = e.NewValue); binding.Unbind(); c1.Bar = "bar"; Assert.IsNull(this.newVal); }
public void WeakBindingListensToEmptyString() { var c1 = new NotifyingClass(); c1.Bar = "bar"; c1.BindWeak(x => x.Bar, (o, e) => this.newVal = e.NewValue); c1.NotifyAll(); Assert.AreEqual("bar", this.newVal); }
public IEventBinding BindWeak(NotifyingClass notifying) { return(notifying.BindWeak(x => x.Foo, (o, e) => this.LastFoo = e.NewValue)); }
public void BindWeakThrowsIfTargetIsCompilerGenerated() { var c1 = new NotifyingClass(); string newVal = null; Assert.Throws<InvalidOperationException>(() => c1.BindWeak(x => x.Foo, (o, e) => newVal = e.NewValue)); }
public IEventBinding BindWeak(NotifyingClass notifying) { return notifying.BindWeak(x => x.Foo, (o, e) => this.LastFoo = e.NewValue); }