Пример #1
0
        public void TestPocoNestedSameType()
        {
            var obj = new SomeObj2().Observable();
            Assert.IsTrue(obj is SomeObj2);

            int notifyCount = 0;

            (obj as IObjectObservable).PropertyChanged2 += (source, propertyName, oldValue, newValue) =>
            {
                notifyCount++;
            };

            obj.NestedSameClass = new SomeObj2();
            Assert.IsTrue(obj.NestedSameClass is IObjectObservable);
            obj.NestedSameClass.NestedObj = new SomeObj();
            Assert.AreEqual(2, notifyCount);
            Assert.IsNotNull(obj.NestedSameClass.NestedObj);
        }
Пример #2
0
        public void TestPocoNested()
        {
            var obj = new SomeObj2().Observable();
            Assert.IsTrue(obj is SomeObj2);

            bool observerNotified = false;

            (obj as IObjectObservable).PropertyChanged2 += (source, propertyName, oldValue, newValue) =>
            {
                Assert.AreEqual("NestedObj", propertyName);
                Assert.IsTrue(source is SomeObj2);
                Assert.IsTrue(newValue is SomeObj);
                observerNotified = true;
            };

            obj.NestedObj = new SomeObj();
            Assert.IsTrue(obj.NestedObj is IObjectObservable);
            obj.NestedObj.IntProp = 10;
            Assert.IsTrue(observerNotified);
            Assert.AreEqual(10, obj.NestedObj.IntProp);
        }