public void ThreeLevels() { var fake = new Fake(); var observable = new PropertyPathObservable <Fake, bool>(fake, x => x.Next.Next.IsTrue); observable.Subscribe(_changes.Add); fake.Next = new Level(); Assert.AreEqual(0, _changes.Count); fake.Next.Next = new Level { Next = new Level() }; Assert.AreEqual(1, _changes.Count); fake.Next.Next = null; Assert.AreEqual(2, _changes.Count); fake.Next = null; Assert.AreEqual(2, _changes.Count); fake.Next = new Level { Next = new Level { IsTrue = true } }; Assert.AreEqual(3, _changes.Count); fake.Next.Next.IsTrue = false; Assert.AreEqual(4, _changes.Count); fake.Next.Next = null; Assert.AreEqual(5, _changes.Count); fake.Next = null; Assert.AreEqual(5, _changes.Count); }
public void SubscribeToExistsingChangeLastValueInPath() { var fake = new Fake { Next = new Level() }; var observable = new PropertyPathObservable <Fake, bool>(fake, x => x.Next.IsTrue); observable.Subscribe(_changes.Add); fake.Next.IsTrue = !fake.Next.IsTrue; Assert.AreEqual(1, _changes.Count); }
public void TwoLevelsValueType() { var fake = new Fake(); var observable = new PropertyPathObservable <Fake, bool>(fake, x => x.Next.IsTrue); observable.Subscribe(_changes.Add); fake.Next = new Level(); Assert.AreEqual(1, _changes.Count); fake.Next.IsTrue = !fake.Next.IsTrue; Assert.AreEqual(2, _changes.Count); fake.Next = null; Assert.AreEqual(3, _changes.Count); }
public void TwoLevelsReferenceType() { var fake = new Fake(); var observable = new PropertyPathObservable <Fake, Level>(fake, x => x.Next.Next); observable.Subscribe(_changes.Add); fake.Next = new Level(); Assert.AreEqual(0, _changes.Count); fake.Next.Next = new Level(); Assert.AreEqual(1, _changes.Count); fake.Next.Next = null; Assert.AreEqual(2, _changes.Count); fake.Next = null; Assert.AreEqual(2, _changes.Count); }
public void TwoLevelsExisting() { var fake = new Fake { Next = new Level { Next = new Level() } }; var observable = new PropertyPathObservable <Fake, Level>(fake, x => x.Next.Next); observable.Subscribe(_changes.Add); fake.Next.Next = new Level(); Assert.AreEqual(1, _changes.Count); fake.Next.Next = null; Assert.AreEqual(2, _changes.Count); fake.Next = null; Assert.AreEqual(2, _changes.Count); }
public void Unsubscribes() { var fake = new Fake(); var observable = new PropertyPathObservable <Fake, bool>(fake, x => x.Next.IsTrue); observable.Subscribe(_changes.Add); fake.Next = new Level { Next = new Level() }; Assert.AreEqual(1, _changes.Count); var temp = fake.Next; fake.Next = null; Assert.AreEqual(2, _changes.Count); temp.IsTrue = !temp.IsTrue; Assert.AreEqual(2, _changes.Count); }