예제 #1
0
        public void PropertyDataObjectRecognized()
        {
            GenericExpressionEvalWrapper.ClearRegisteredTypes();
            string           testString = "Test String";
            SimpleDataObject data       = new SimpleDataObject(1, testString, 2.2);

            GenericExpressionEvalWrapper wrapper = new GenericExpressionEvalWrapper(data);

            int invokerCount = GenericExpressionEvalWrapper.GetDataFieldEvaluator(data.GetType()).Count;

            Assert.AreEqual(invokerCount, 0);

            Assert.Less(0, GenericExpressionEvalWrapper.GetDataPropertyEvaluator(data.GetType()).Count, "Property invokers not loaded");
        }
예제 #2
0
        public void PropertyObjectInvokersLoad()
        {
            GenericExpressionEvalWrapper.ClearRegisteredTypes();
            string      valExpr = "MyString";
            DataContext context = new DataContext();

            string           testString = "Test String";
            SimpleDataObject data       = new SimpleDataObject(1, testString, 2.2);

            GenericExpressionEvalWrapper wrapper = new GenericExpressionEvalWrapper(data, false);

            object rslt = wrapper.ResolveExpressionValue(valExpr);

            Assert.IsNotNull(rslt, "Result is null");
            string result = rslt.ToString();

            Assert.AreEqual(testString, result, "Direct ResolveExpressionValue call failed");
            Assert.AreEqual(result, WrapperUtility.ResolveExpressionValue(valExpr, data, GenericExpressionEvalWrapper.GetDataPropertyEvaluator(data.GetType())));

            DataContext dc = new DataContext();

            dc.RegisterDataItem("foo", wrapper);

            string dcResult = dc.CalculateVariableValue("${foo." + valExpr + "}");

            Assert.AreEqual(testString, dcResult, "DataContext gave incorrect result");
        }