public void EntitySetIsSetCorrectly() { EntitySetNode entitySetNode = new EntitySetNode(HardCodedTestModel.GetDogsSet()); EntityRangeVariable entityRangeVariable = new EntityRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode); entityRangeVariable.NavigationSource.Should().Be(HardCodedTestModel.GetDogsSet()); }
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); }
public void EntityTypeCannotBeNull() { EntityCollectionNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet()); Action createWithNullEntityType = () => new EntityCollectionCastNode(source, null); createWithNullEntityType.ShouldThrow <Exception>(Error.ArgumentNull("entityType").ToString()); }
public void EntityItemTypeIsSameAsItemType() { EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet()); CollectionResourceCastNode collectionResourceCastNode = new CollectionResourceCastNode(source, HardCodedTestModel.GetDogType()); collectionResourceCastNode.ItemStructuredType.Should().BeSameAs(collectionResourceCastNode.ItemType); }
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); }
public void KindIsEntityCollectionCastNode() { EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet()); EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType()); entityCollectionCastNode.InternalKind.Should().Be(InternalQueryNodeKind.EntityCollectionCast); }
public void CreateParameterNodeShouldKeepParameterNameExactlyTheSame() { var nodeToIterationOver = new EntitySetNode(HardCodedTestModel.GetPeopleSet()); var resultNode = NodeFactory.CreateParameterNode("PARAM_name!@#", nodeToIterationOver); resultNode.Name.Should().Be("PARAM_name!@#"); }
public void EntityTypeReferenceReturnsEdmEntityTypeReference() { EntitySetNode entitySetNode = new EntitySetNode(HardCodedTestModel.GetDogsSet()); ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode); entityRangeVariable.StructuredTypeReference.Should().BeOfType <EdmEntityTypeReference>(); }
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()); }
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()); }
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); }
public void EntitySetComesFromSource() { EntitySetNode source = new EntitySetNode(HardCodedTestModel.GetDogsSet()); EntityCollectionCastNode entityCollectionCastNode = new EntityCollectionCastNode(source, HardCodedTestModel.GetDogType()); entityCollectionCastNode.NavigationSource.Should().Be(HardCodedTestModel.GetDogsSet()); }
public void KindShouldBeEntityRangeVariable() { EntitySetNode entitySetNode = new EntitySetNode(HardCodedTestModel.GetDogsSet()); ResourceRangeVariable entityRangeVariable = new ResourceRangeVariable("dogs", HardCodedTestModel.GetDogTypeReference(), entitySetNode); entityRangeVariable.Kind.Should().Be(RangeVariableKind.Resource); }
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()); }
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(); }
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); }
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()); }
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())); }
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()); }
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())); }
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); }
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); }
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); }
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"); }