public void BindToSmokeTest() { (new TestScheduler()).With(sched => { var input = new Subject<string>(sched); var fixture = new HostTestFixture() {Child = new TestFixture()}; input.BindTo(fixture, x => x.Child.IsNotNullString); Assert.Null(fixture.Child.IsNotNullString); input.OnNext("Foo"); sched.Run(); Assert.Equal("Foo", fixture.Child.IsNotNullString); input.OnNext("Bar"); sched.Run(); Assert.Equal("Bar", fixture.Child.IsNotNullString); }); }
public void DisposingDisconnectsTheBindTo() { (new TestScheduler()).With(sched => { var input = new Subject<string>(sched); var fixture = new HostTestFixture() {Child = new TestFixture()}; var subscription = input.BindTo(fixture, x => x.Child.IsNotNullString); Assert.Null(fixture.Child.IsNotNullString); input.OnNext("Foo"); sched.Run(); Assert.Equal("Foo", fixture.Child.IsNotNullString); subscription.Dispose(); input.OnNext("Bar"); sched.Run(); Assert.Equal("Foo", fixture.Child.IsNotNullString); }); }
public void BindToIsNotFooledByIntermediateObjectSwitching() { (new TestScheduler()).With(sched => { var input = new Subject<string>(sched); var fixture = new HostTestFixture() {Child = new TestFixture()}; var subscription = input.BindTo(fixture, x => x.Child.IsNotNullString); Assert.Null(fixture.Child.IsNotNullString); input.OnNext("Foo"); sched.Run(); Assert.Equal("Foo", fixture.Child.IsNotNullString); fixture.Child = new TestFixture(); sched.Run(); Assert.Null(fixture.Child.IsNotNullString); input.OnNext("Bar"); sched.Run(); Assert.Equal("Bar", fixture.Child.IsNotNullString); }); }