public void OpenPropertyIsNotBoundToAFunction()
 {
     var token = new EndPathToken("SomeOpenProperty", null);
     BindingState state = GetBindingStateForTest(HardCodedTestModel.GetPaintingTypeReference(), HardCodedTestModel.GetPaintingsSet());
     EndPathBinder binder = new EndPathBinder(BindMethod, state);
     var result = binder.BindEndPath(token);
     result.ShouldBeSingleValueOpenPropertyAccessQueryNode("SomeOpenProperty");
 }
 public void Init()
 {
     this.bindingState = GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
     this.propertyBinder = new EndPathBinder(BindMethod, this.bindingState);
 }
Example #3
0
        public void ShouldNotThrowIfTypeNotOpenButAggregateApplied()
        {
            var token = new EndPathToken("Color", new RangeVariableToken("a"));
            EntityCollectionNode entityCollectionNode = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            SingleValueNode parentNode = new EntityRangeVariableReferenceNode("a", new EntityRangeVariable("a", HardCodedTestModel.GetPersonTypeReference(), entityCollectionNode));

            var state = new BindingState(this.configuration);
            state.AggregatedPropertyNames = new List<string> { "Color" };
            var metadataBinder = new MetadataBinder(state);
            var endPathBinder = new EndPathBinder(metadataBinder.Bind, state);
            var propertyNode = endPathBinder.GeneratePropertyAccessQueryForOpenType(
                token, parentNode);

            propertyNode.ShouldBeSingleValueOpenPropertyAccessQueryNode("Color");
        }
Example #4
0
        public void ShouldThrowIfTypeNotOpen()
        {
            var token = new EndPathToken("Color", new RangeVariableToken("a"));
            EntityCollectionNode entityCollectionNode = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            SingleValueNode parentNode = new EntityRangeVariableReferenceNode("a", new EntityRangeVariable("a", HardCodedTestModel.GetPersonTypeReference(), entityCollectionNode));

            var state = new BindingState(this.configuration);
            var metadataBinder = new MetadataBinder(state);
            var endPathBinder = new EndPathBinder(metadataBinder.Bind, state);
            Action getQueryNode = () => endPathBinder.GeneratePropertyAccessQueryForOpenType(
                token, parentNode);

            getQueryNode.ShouldThrow<ODataException>().WithMessage(
                Strings.MetadataBinder_PropertyNotDeclared(parentNode.GetEdmTypeReference().FullName(),
                                                                                    token.Identifier));
        }
Example #5
0
        public void ShouldThrowNotImplementedIfTypeIsOpen()
        {
            const string OpenPropertyName = "Style";
            var token = new EndPathToken(OpenPropertyName, new RangeVariableToken("a"));
            EntityCollectionNode entityCollectionNode = new EntitySetNode(HardCodedTestModel.GetPaintingsSet());
            SingleValueNode parentNode = new EntityRangeVariableReferenceNode("a", new EntityRangeVariable("a", HardCodedTestModel.GetPaintingTypeReference(), entityCollectionNode));
            
            var state = new BindingState(this.configuration);
            var metadataBinder = new MetadataBinder(state);
            var endPathBinder = new EndPathBinder(metadataBinder.Bind, state);
            var propertyNode = endPathBinder.GeneratePropertyAccessQueryForOpenType(
                token, parentNode);

            propertyNode.ShouldBeSingleValueOpenPropertyAccessQueryNode(OpenPropertyName);
        }
Example #6
0
        /// <summary>
        /// Binds a property access token.
        /// </summary>
        /// <param name="endPathToken">The property access token to bind.</param>
        /// <returns>The bound property access token.</returns>
        protected virtual QueryNode BindEndPath(EndPathToken endPathToken)
        {
            EndPathBinder endPathBinder = new EndPathBinder(this.Bind, this.BindingState);

            return(endPathBinder.BindEndPath(endPathToken));
        }
Example #7
0
 /// <summary>
 /// Binds a property access token.
 /// </summary>
 /// <param name="endPathToken">The property access token to bind.</param>
 /// <returns>The bound property access token.</returns>
 protected virtual QueryNode BindEndPath(EndPathToken endPathToken)
 {
     EndPathBinder endPathBinder = new EndPathBinder(this.Bind, this.BindingState);
     return endPathBinder.BindEndPath(endPathToken);
 }