public void StrongBindingPassesTarget() { var c1 = new NotifyingClass(); object sender = null; c1.Bind(x => x.Foo, (o, e) => sender = o); c1.Foo = "foo"; Assert.AreEqual(c1, sender); }
public void StrongBindingIgnoresOtherProperties() { string newVal = null; var c1 = new NotifyingClass(); c1.Bind(x => x.Bar, (o, e) => newVal = e.NewValue); c1.Foo = "bar"; Assert.AreEqual(null, newVal); }
public void StrongBindingBinds() { string newVal = null; var c1 = new NotifyingClass(); c1.Bind(x => x.Foo, (o, e) => newVal = e.NewValue); c1.Foo = "bar"; Assert.AreEqual("bar", newVal); }
public void StrongBindingListensToEmptyString() { string newVal = null; var c1 = new NotifyingClass(); c1.Bar = "bar"; c1.Bind(x => x.Bar, (o, e) => newVal = e.NewValue); c1.NotifyAll(); Assert.AreEqual("bar", newVal); }
public void StrongBindingUnbinds() { string newVal = null; var c1 = new NotifyingClass(); var binding = c1.Bind(x => x.Bar, (o, e) => newVal = e.NewValue); binding.Unbind(); c1.Bar = "bar"; Assert.AreEqual(null, newVal); }
public IEventBinding BindStrong(NotifyingClass notifying) { // Must make sure the compiler doesn't generate an inner class for this, otherwise we're not testing the right thing return(notifying.Bind(x => x.Foo, (o, e) => this.LastFoo = e.NewValue)); }
public IEventBinding BindStrong(NotifyingClass notifying) { // Must make sure the compiler doesn't generate an inner class for this, otherwise we're not testing the right thing return notifying.Bind(x => x.Foo, (o, e) => this.LastFoo = e.NewValue); }