Beispiel #1
0
        public void TwoPropertiesWithImplicitConversionSerializeTest()
        {
            Expression <Func <SecurityDbContext, DbContextObject1, bool> > criteria = (db, obj) => obj.ItemCount < obj.DecimalItem;
            CriteriaSerializer criteriaSerializer = new CriteriaSerializer();
            XElement           serialized         = criteriaSerializer.SerializeAsXElement(criteria);

            string property1Type = "System.Int32";
            string property2Type = "System.Decimal";
            string property1Name = "ItemCount";
            string property2Name = "DecimalItem";
            string objectName    = "obj";
            string objectType    = "DevExpress.EntityFramework.SecurityDataStore.Tests.DbContexts.DbContextObject1";

            XElement nominal = SerializeTestHelper.CreateBaseCriteriaXElement(objectType);

            XElement implicitConversionMethod = SerializeTestHelper.GetSingleParameterMethod("op_Implicit", "System.Decimal", "System.Int32");
            XElement lessThanMethod           = SerializeTestHelper.GetMethod("op_LessThan", "System.Decimal", new string[] { "System.Decimal", "System.Decimal" });

            XElement right = SerializeTestHelper.GetMemberExpression(objectType, objectName, property2Type, property2Name);
            XElement left  = SerializeTestHelper.GetMemberConvertUnaryExpression(property2Type, objectType, objectName, property1Type, property1Name);

            SerializeTestHelper.SetMethodElement(left, implicitConversionMethod);

            XElement body = SerializeTestHelper.GetBinaryExpression("LessThan",
                                                                    right,
                                                                    left
                                                                    );

            SerializeTestHelper.SetMethodElement(body, lessThanMethod);

            SerializeTestHelper.SetLambdaBody(nominal, body);
            SerializeTestHelper.CheckIfNominalAndSerializedAreEqual(nominal, serialized);
        }