Ejemplo n.º 1
0
        private ExpressionState GetState()
        {
            var context = TestScenarioCreator.GetTestEvaluationContext();
            var state   = new ExpressionState(context);

            return(state);
        }
Ejemplo n.º 2
0
        public void TestConstruction()
        {
            var context = TestScenarioCreator.GetTestEvaluationContext();
            var state   = new ExpressionState(context);

            Assert.Equal(context, state.EvaluationContext);
        }
Ejemplo n.º 3
0
        public void TestRootObjectConstructor()
        {
            var ctx = GetContext();

            // TypedValue root = ctx.getRootObject();
            // supplied should override root on context
            var state     = new ExpressionState(ctx, new TypedValue("i am a string"));
            var stateRoot = state.RootContextObject;

            Assert.Equal(typeof(string), stateRoot.TypeDescriptor);
            Assert.Equal("i am a string", stateRoot.Value);
        }
Ejemplo n.º 4
0
        public void TestRootContextObject()
        {
            var state = GetState();

            Assert.IsType <Inventor>(state.RootContextObject.Value);

            // although the root object is being set on the evaluation context, the value in the 'state' remains what it was when constructed
            ((StandardEvaluationContext)state.EvaluationContext).SetRootObject(null);
            Assert.IsType <Inventor>(state.RootContextObject.Value);

            // assertEquals(null, state.RootContextObject.Value);
            state = new ExpressionState(new StandardEvaluationContext());
            Assert.Equal(TypedValue.NULL, state.RootContextObject);

            ((StandardEvaluationContext)state.EvaluationContext).SetRootObject(null);
            Assert.Null(state.RootContextObject.Value);
        }
Ejemplo n.º 5
0
        public void TestActiveContextObject()
        {
            var state = GetState();

            Assert.Equal(state.RootContextObject.Value, state.GetActiveContextObject().Value);

            Assert.Throws <InvalidOperationException>(() => state.PopActiveContextObject());

            state.PushActiveContextObject(new TypedValue(34));
            Assert.Equal(34, state.GetActiveContextObject().Value);

            state.PushActiveContextObject(new TypedValue("hello"));
            Assert.Equal("hello", state.GetActiveContextObject().Value);

            state.PopActiveContextObject();
            Assert.Equal(34, state.GetActiveContextObject().Value);

            state.PopActiveContextObject();
            Assert.Equal(state.RootContextObject.Value, state.GetActiveContextObject().Value);

            state = new ExpressionState(new StandardEvaluationContext());
            Assert.Equal(TypedValue.NULL, state.GetActiveContextObject());
        }