Ejemplo n.º 1
0
        public void ObserveTwoProperties()
        {
            var obj = new LotsOfProperties();
            Tuple<int, string> current = null;
            obj.ObserveProperties(x => x.IntProperty, x => x.StringProperty, (x, y) => Tuple.Create(x, y)).Subscribe(x => current = x);

            Assert.AreEqual(0, current.Item1);
            Assert.AreEqual(null, current.Item2);

            obj.IntProperty = 1;
            Assert.AreEqual(1, current.Item1);
            Assert.AreEqual(null, current.Item2);

            obj.StringProperty = "foo";
            Assert.AreEqual(1, current.Item1);
            Assert.AreEqual("foo", current.Item2);
        }
Ejemplo n.º 2
0
        public void ObserveThreeProperties()
        {
            var obj = new LotsOfProperties();
            Tuple<int, string, string> current = null;
            obj.ObserveProperties(x => x.IntProperty, x => x.StringProperty, x => x.TestObjectProperty.StringProperty, (x, y, z) => Tuple.Create(x, y, z)).Subscribe(x => current = x);

            Assert.AreEqual(0, current.Item1);
            Assert.AreEqual(null, current.Item2);
            Assert.AreEqual(null, current.Item3);

            obj.IntProperty = 1;
            Assert.AreEqual(1, current.Item1);
            Assert.AreEqual(null, current.Item2);
            Assert.AreEqual(null, current.Item3);

            obj.StringProperty = "foo";
            Assert.AreEqual(1, current.Item1);
            Assert.AreEqual("foo", current.Item2);
            Assert.AreEqual(null, current.Item3);

            obj.TestObjectProperty = new TestObject();
            obj.TestObjectProperty.StringProperty = "bar";
            Assert.AreEqual(1, current.Item1);
            Assert.AreEqual("foo", current.Item2);
            Assert.AreEqual("bar", current.Item3);
        }