Exemple #1
0
 public void TestPeekWithDeferEvaluation()
 {
     int timesEvaluated = 0;
     var computed = new ComputedObservable<int>(() =>
     {
         timesEvaluated++;
         return 123;
     },
         true);
     Assert.AreEqual(0, timesEvaluated);
     Assert.AreEqual(123, computed.Peek());
     Assert.AreEqual(123, computed.Peek());
     Assert.AreEqual(1, timesEvaluated);
 }
Exemple #2
0
 public void TestPeekComputed()
 {
     var underlyingProperty = new ObservableProperty<int>(1);
     var computed1 = new ComputedObservable<int>(() => 1 + underlyingProperty);
     var computed2 = new ComputedObservable<int>(() => 1 + computed1.Peek());
     Assert.AreEqual(3, computed2.Value);
     Assert.AreEqual(0, computed2.DependencyCount);
     underlyingProperty.Value = 11;
     Assert.AreEqual(3, computed2.Value);
 }