public void TestNestedExpressions()
        {
            var term1 = new ReactiveVar <int>(1);
            var term2 = new ReactiveVar <int>(2);

            var           subexpression = new ReactiveExpression <int>(() => term1.Value + term2.Value);
            ChangedCalled subexpressionChangedCalled = EnsureChangedCalled(subexpression);

            var           term3                  = new ReactiveVar <int>(3);
            var           expression             = new ReactiveExpression <int>(() => subexpression.Value + term3.Value);
            ChangedCalled expressionChangeCalled = EnsureChangedCalled(expression);

            Transaction.Start();
            term3.Set(5);
            CompleteTransactionAndAssertChangedCalled(expressionChangeCalled);
            Assert.AreEqual(8, expression.Value);

            expressionChangeCalled.Reset();
            Transaction.Start();
            term1.Set(10);
            CompleteTransactionAndAssertChangedCalled(expressionChangeCalled);
            subexpressionChangedCalled.AssertCalled();

            Assert.AreEqual(17, expression.Value);
        }
        public void TestSet()
        {
            var           reactiveVar   = new ReactiveVar <int>(1);
            ChangedCalled changedCalled = EnsureChangedCalled(reactiveVar);

            Transaction.Start();
            reactiveVar.Set(2);
            changedCalled.AssertNotCalled();

            Transaction.End();
            changedCalled.AssertCalled();

            Assert.AreEqual(2, reactiveVar.Value);
        }
Пример #3
0
 protected static void CompleteTransactionAndAssertChangedCalled(ChangedCalled changedCalled)
 {
     changedCalled.AssertNotCalled();
     Transaction.End();
     changedCalled.AssertCalled();
 }