Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 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);
 }
Exemple #4
0
        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);
        }
Exemple #5
0
 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);
 }