Exemplo n.º 1
0
        public void LocalRegistedDataKeyDictionaryVariable()
        {
            DataContext dc       = new DataContext();
            string      expected = AccountTestData.viewerName;


            GenericExpressionEvalWrapper wrappedPerson = new GenericExpressionEvalWrapper(AccountTestData.Viewer);

            string val = wrappedPerson.ResolveExpressionValue("displayName") as string;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            string dictKey   = "foo";
            string localKey  = "mydict";
            string globalKey = "vwr";


            dict.Add(dictKey, AsKey(globalKey));

            dc.RegisterDataItem(globalKey, wrappedPerson);

            dc.RegisterLocalValue(localKey, dict, true);

            string expr = AsKey(String.Format("{0}.{1}.displayName", new object[] { localKey, dictKey }));

            string result = dc.GetVariableValue(expr);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 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");
        }
Exemplo n.º 3
0
        public void FieldAndPropertyContractWorks()
        {
            GenericExpressionEvalWrapper.ClearRegisteredTypes();
            string testString       = "Test String";
            string propNameValue    = "Steve";
            string fieldZodiacValue = "Aquarius";
            Person data             = new Person();

            data.DisplayName = propNameValue;
            data.ZodiacSign  = fieldZodiacValue;            //field value


            GenericExpressionEvalWrapper wrapper = new GenericExpressionEvalWrapper(data);

            Assert.AreEqual(fieldZodiacValue, wrapper.ResolveExpressionValue("msZodiacSign"), "Field failed evaluation");
            Assert.AreEqual(propNameValue, wrapper.ResolveExpressionValue("displayName"), "Property failed evaluation");
        }