Пример #1
0
        private static void VerifyEnumVsStringFilterExpressionReverse(FilterClause filter)
        {
            var enumtypeRef = new EdmEnumTypeReference(UriEdmHelpers.FindEnumTypeFromModel(HardCodedTestModel.TestModel, "Fully.Qualified.Namespace.ColorPattern"), true);
            var bin         = filter.Expression.ShouldBeBinaryOperatorNode(BinaryOperatorKind.Equal);

            bin.Right.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPet2PetColorPatternProperty());
            bin.Left.ShouldBeEnumNode(enumtypeRef.EnumDefinition(), "2");
        }
        public void TestEnumAsStringHas()
        {
            Uri unqualifiedEnumUri = new Uri("http://host/Pet2Set?$filter=PetColorPattern has 'Blue'");

            var uriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, unqualifiedEnumUri)
            {
                Resolver = new StringAsEnumResolver()
            };

            var filter = uriParser.ParseFilter();

            var enumtypeRef = new EdmEnumTypeReference(UriEdmHelpers.FindEnumTypeFromModel(HardCodedTestModel.TestModel, "Fully.Qualified.Namespace.ColorPattern"), true);
            var bin         = filter.Expression.ShouldBeBinaryOperatorNode(BinaryOperatorKind.Has);

            bin.Left.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPet2PetColorPatternProperty());
            bin.Right.ShouldBeStringCompatibleEnumNode(enumtypeRef.EnumDefinition(), "2");
        }