public void ThreeLevels()
        {
            var args       = new List <EventPattern <PropertyChangedEventArgs> >();
            var fake       = new FakeInpc();
            var observable = new NestedObservable <FakeInpc, bool>(fake, x => x.Next.Next.Value);

            observable.Subscribe(args.Add);
            fake.Next = new Level();
            Assert.AreEqual(0, args.Count);
            fake.Next.Next = new Level
            {
                Next = new Level()
            };
            Assert.AreEqual(1, args.Count);
            fake.Next.Next = null;
            Assert.AreEqual(2, args.Count);
            fake.Next = null;
            Assert.AreEqual(2, args.Count);
            fake.Next = new Level
            {
                Next = new Level
                {
                    Value = true
                }
            };
            Assert.AreEqual(3, args.Count);
            fake.Next.Next.Value = false;
            Assert.AreEqual(4, args.Count);
            fake.Next.Next = null;
            Assert.AreEqual(5, args.Count);
            fake.Next = null;
            Assert.AreEqual(5, args.Count);
        }
        public void TwoLevelsValueType()
        {
            var args       = new List <EventPattern <PropertyChangedEventArgs> >();
            var fake       = new FakeInpc();
            var observable = new NestedObservable <FakeInpc, bool>(fake, x => x.Next.Value);

            observable.Subscribe(args.Add);
            fake.Next = new Level();
            Assert.AreEqual(1, args.Count);
            fake.Next.Value = !fake.Next.Value;
            Assert.AreEqual(2, args.Count);
            fake.Next = null;
            Assert.AreEqual(3, args.Count);
        }
        public void TwoLevelsExisting()
        {
            var args = new List <EventPattern <PropertyChangedEventArgs> >();
            var fake = new FakeInpc {
                Next = new Level {
                    Next = new Level()
                }
            };
            var observable = new NestedObservable <FakeInpc, Level>(fake, x => x.Next.Next);

            observable.Subscribe(args.Add);
            fake.Next.Next = new Level();
            Assert.AreEqual(1, args.Count);
            fake.Next.Next = null;
            Assert.AreEqual(2, args.Count);
            fake.Next = null;
            Assert.AreEqual(2, args.Count);
        }