public void EntitySetIsSetCorrectly()
        {
            EntitySetNode       entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityRangeVariable entityRangeVariable = new EntityRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            entityRangeVariable.NavigationSource.Should().Be(HardCodedTestModel.GetDogsSet());
        }
Exemplo n.º 2
0
        public void ItemTypeReturnsEdmEntityTypeReference()
        {
            EntitySetNode            source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType());

            entityCollectionCastNode.ItemType.Should().BeOfType <EdmEntityTypeReference>();
        }
        public void EntitySetIsSetCorrectly()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            Assert.Same(HardCodedTestModel.GetDogsSet(), entityRangeVariable.NavigationSource);
        }
Exemplo n.º 4
0
        public void EntityTypeCannotBeNull()
        {
            EntityCollectionNode source     = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            Action createWithNullEntityType = () => new EntityCollectionCastNode(source, null);

            createWithNullEntityType.ShouldThrow <Exception>(Error.ArgumentNull("entityType").ToString());
        }
Exemplo n.º 5
0
        public void EntityItemTypeIsSameAsItemType()
        {
            EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            CollectionResourceCastNode collectionResourceCastNode = new CollectionResourceCastNode(source, HardCodedTestModel.GetDogType());

            collectionResourceCastNode.ItemStructuredType.Should().BeSameAs(collectionResourceCastNode.ItemType);
        }
Exemplo n.º 6
0
        public void SourceIsSetCorrectly()
        {
            EntitySetNode            source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType());

            entityCollectionCastNode.Source.ShouldBeEntitySetQueryNode(HardCodedTestModel.GetDogsSet());
        }
        public void ItemTypeReturnsEdmEntityTypeReference()
        {
            EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            CollectionResourceCastNode collectionResourceCastNode = new CollectionResourceCastNode(source, HardCodedTestModel.GetDogType());

            Assert.IsType <EdmEntityTypeReference>(collectionResourceCastNode.ItemType);
        }
        public void StructuredTypeCannotBeNull()
        {
            CollectionResourceNode source   = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            Action createWithNullEntityType = () => new CollectionResourceCastNode(source, null);

            Assert.Throws <ArgumentNullException>("structuredType", createWithNullEntityType);
        }
        public void KindIsCollectionResourceCastNode()
        {
            EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            CollectionResourceCastNode collectionResourceCastNode = new CollectionResourceCastNode(source, HardCodedTestModel.GetDogType());

            Assert.Equal(collectionResourceCastNode.InternalKind, InternalQueryNodeKind.CollectionResourceCast);
        }
Exemplo n.º 10
0
        public void KindIsEntityCollectionCastNode()
        {
            EntitySetNode            source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType());

            entityCollectionCastNode.InternalKind.Should().Be(InternalQueryNodeKind.EntityCollectionCast);
        }
Exemplo n.º 11
0
        public void CreateParameterNodeShouldKeepParameterNameExactlyTheSame()
        {
            var nodeToIterationOver = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
            var resultNode          = NodeFactory.CreateParameterNode("PARAM_name!@#", nodeToIterationOver);

            resultNode.Name.Should().Be("PARAM_name!@#");
        }
Exemplo n.º 12
0
        public void EntityTypeReferenceReturnsEdmEntityTypeReference()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            entityRangeVariable.StructuredTypeReference.Should().BeOfType <EdmEntityTypeReference>();
        }
Exemplo n.º 13
0
        public void TypeReferenceIsSetCorrectly()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            entityRangeVariable.TypeReference.FullName().Should().Be(HardCodedTestModel.GetDogTypeReference().FullName());
        }
Exemplo n.º 14
0
        public void EntityItemTypeIsSameAsItemType()
        {
            EntitySetNode            source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType());

            entityCollectionCastNode.EntityItemType.Should().BeSameAs(entityCollectionCastNode.ItemType);
        }
        public void EntitySetComesFromSource()
        {
            EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            CollectionResourceCastNode collectionResourceCastNode = new CollectionResourceCastNode(source, HardCodedTestModel.GetDogType());

            Assert.Same(collectionResourceCastNode.NavigationSource, HardCodedTestModel.GetDogsSet());
        }
Exemplo n.º 16
0
        public void EntityCollectionNodeIsSetCorrectly()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            entityRangeVariable.CollectionResourceNode.ShouldBeEntitySetQueryNode(HardCodedTestModel.GetDogsSet());
        }
        public void TypeReferenceReturnsEdmEntityTypeReference()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            Assert.IsType <EdmEntityTypeReference>(entityRangeVariable.TypeReference);
        }
Exemplo n.º 18
0
        public void EntitySetComesFromSource()
        {
            EntitySetNode            source = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType());

            entityCollectionCastNode.NavigationSource.Should().Be(HardCodedTestModel.GetDogsSet());
        }
Exemplo n.º 19
0
        public void KindShouldBeEntityRangeVariable()
        {
            EntitySetNode         entitySetNode       = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            entityRangeVariable.Kind.Should().Be(RangeVariableKind.Resource);
        }
Exemplo n.º 20
0
        public void CreateParameterNodeShouldReturnEntityParameterQueryNodeForEntityType()
        {
            var nodeToIterationOver = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
            var resultNode          = NodeFactory.CreateParameterNode("a", nodeToIterationOver);

            resultNode.ShouldBeResourceRangeVariable(HardCodedTestModel.GetPersonTypeReference())
            .CollectionResourceNode.NavigationSource.Should().Be(HardCodedTestModel.GetPeopleSet());
        }
Exemplo n.º 21
0
        public void CanCreateFromEntitySetOrEntityCollectionNode()
        {
            EntitySetNode entitySetNode            = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            Action        createWithEntityset      = () => new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), HardCodedTestModel.GetDogsSet());
            Action        createWithCollectionNode = () => new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode);

            createWithEntityset.ShouldNotThrow();
            createWithCollectionNode.ShouldNotThrow();
        }
Exemplo n.º 22
0
        public void KeyLookupOnEntitySetWithNamedKeyReturnsKeyLookupQueryNode()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
            var namedValues    = new[] { new NamedValue("ID", new LiteralToken(123)) };

            var results = this.keyBinder.BindKeyValues(collectionNode, namedValues, model);

            Assert.Equal(FakeBindMethods.KeyBinderConstantToken, results.ShouldBeKeyLookupQueryNode().KeyPropertyValues.Single().KeyValue);
        }
Exemplo n.º 23
0
        public void KeyLookupWithTwoKeysReturnsKeyLookupQueryNodeWithTwoKeyProperties()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetLionSet());
            var namedValues    = new[] { new NamedValue("ID1", new LiteralToken(123)), new NamedValue("ID2", new LiteralToken(456)) };

            var results = this.keyBinder.BindKeyValues(collectionNode, namedValues, model);

            Assert.Equal(2, results.ShouldBeKeyLookupQueryNode().KeyPropertyValues.Count());
        }
Exemplo n.º 24
0
        public void KeyLookupWithMultipleUnnamedKeysShouldThrow()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetLionSet());
            var namedValues    = new[] { new NamedValue(null, new LiteralToken(123)), new NamedValue(null, new LiteralToken(456)), };

            Action bind = () => this.keyBinder.BindKeyValues(collectionNode, namedValues, model);

            bind.Throws <ODataException>(Strings.MetadataBinder_UnnamedKeyValueOnTypeWithMultipleKeyProperties(HardCodedTestModel.GetLionSet().EntityType().FullTypeName()));
        }
Exemplo n.º 25
0
        public void EntitySetWithNoKeysShouldBeJustBeEntitySetQueryNode()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
            var namedValues    = new NamedValue[0];

            var results = this.keyBinder.BindKeyValues(collectionNode, namedValues, model);

            results.ShouldBeEntitySetQueryNode(HardCodedTestModel.GetPeopleSet());
        }
Exemplo n.º 26
0
        public void KeyLookupWithOneOfTwoKeysMissingShouldThrow()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetLionSet());
            var namedValues    = new[] { new NamedValue("ID1", new LiteralToken(123)) };

            Action bind = () => this.keyBinder.BindKeyValues(collectionNode, namedValues, model);

            bind.Throws <ODataException>(Strings.MetadataBinder_NotAllKeyPropertiesSpecifiedInKeyValues(collectionNode.ItemType.FullName()));
        }
Exemplo n.º 27
0
        public void KeyLookupOnEntitySetReturnsKeyLookupQueryNode()
        {
            var collectionNode = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
            var namedValues    = new[] { new NamedValue(null, new LiteralToken(123)) };

            var results = this.keyBinder.BindKeyValues(collectionNode, namedValues);

            results.ShouldBeKeyLookupQueryNode().And.KeyPropertyValues.Single().KeyValue.Should().Be(FakeBindMethods.KeyBinderConstantToken);
        }
Exemplo n.º 28
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                  propertyNode         = EndPathBinder.GeneratePropertyAccessQueryForOpenType(
                token, parentNode);

            propertyNode.ShouldBeSingleValueOpenPropertyAccessQueryNode(OpenPropertyName);
        }
Exemplo n.º 29
0
        public void GenerateQueryNodeShouldReturnQueryNode()
        {
            var property = HardCodedTestModel.GetDogColorProp();
            EntityCollectionNode entityCollectionNode = new EntitySetNode(HardCodedTestModel.GetDogsSet());
            EntityRangeVariable  rangeVariable        = new EntityRangeVariable("Color", HardCodedTestModel.GetDogTypeReference(), entityCollectionNode);
            var result = EndPathBinder.GeneratePropertyAccessQueryNode(
                new EntityRangeVariableReferenceNode(rangeVariable.Name, rangeVariable),
                property);

            result.ShouldBeSingleValuePropertyAccessQueryNode(property);
        }
Exemplo n.º 30
0
        public void ExplicitPropertyAccessShouldCreatePropertyAccessQueryNode()
        {
            var token = new EndPathToken("Color", new RangeVariableToken("a"));
            EntityCollectionNode entityCollectionNode = new EntitySetNode(HardCodedTestModel.GetDogsSet());

            this.bindingState.RangeVariables.Push(new EntityRangeVariable("a", HardCodedTestModel.GetDogTypeReference(), entityCollectionNode));
            var result = this.propertyBinder.BindEndPath(token);

            result.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetDogColorProp()).
            And.Source.ShouldBeEntityRangeVariableReferenceNode("a");
        }