public void ObservePathChangedArray() { var obj = new ContainerObject(); string value = "error"; obj.ObserveProperty<ContainerObject, string>(typeof(ContainerObject).GetProperty("Test"), typeof(TestObject).GetProperty("StringProperty")).Subscribe(x => value = x); Assert.IsNull(value); var test = new TestObject(); obj.Test = test; Assert.IsNull(value); obj.Test.StringProperty = "foo"; Assert.AreEqual("foo", value); value = "error"; obj.Test = null; value = "pass"; test.StringProperty = "bar"; Assert.AreEqual("pass", value); obj.Test = test; Assert.AreEqual("bar", value); }
public void ObservePathChanged() { var obj = new ContainerObject(); string value = "error"; obj.ObserveProperty(x => x.Test.StringProperty).Subscribe(x => value = x); Assert.IsNull(value); var test = new TestObject(); obj.Test = test; Assert.IsNull(value); obj.Test.StringProperty = "foo"; Assert.AreEqual("foo", value); value = "error"; obj.Test = null; value = "pass"; test.StringProperty = "bar"; Assert.AreEqual("pass", value); obj.Test = test; Assert.AreEqual("bar", value); }
public void ObserveNonObservable() { var container = new ContainerObject(); string s = null; container.ObserveProperty(x => x.Test.NonObservableStringProperty).Subscribe(x => { s = x; }); var testObject = new TestObject(); testObject.NonObservableStringProperty = "foo"; container.Test = testObject; Assert.AreEqual("foo", s); }
public void ObservablePathInt() { var container = new ContainerObject(); int i = 0; container.ObserveProperty(x => x.Test.IntProperty).Subscribe(x => { i = x; }); var testObject = new TestObject(); container.Test = testObject; testObject.IntProperty = 5; Assert.AreEqual(5, i); }
public void ObservePropertyIsDistinct() { var testObject = new TestObject(); var containerObject = new ContainerObject(); var list = new List<string>(); containerObject.ObserveProperty(x => x.Test.StringProperty).Subscribe(x => list.Add(x)); containerObject.Test = testObject; Assert.AreEqual(1, list.Count); }