public void TypeSetCorrectly() { IEdmType type = ModelBuildingHelpers.BuildValidEntityType(); TypeSegment segment = new TypeSegment(type, null); segment.EdmType.Should().BeSameAs(type); }
public void PropertySetCorrectly() { IEdmStructuralProperty prop = ModelBuildingHelpers.BuildValidPrimitiveProperty(); PropertySegment segment = new PropertySegment(prop); segment.Property.Should().Be(prop); }
public void NonEntityTypeIsPassedThrough() { IEdmType nonEntityType = ModelBuildingHelpers.BuildValidComplexType(); ValueSegment segment = new ValueSegment(nonEntityType); segment.EdmType.Should().BeSameAs(nonEntityType); }
public void SetIsCopiedFromPreviousSegment() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); segment.NavigationSource.Should().BeSameAs(set); }
public OperationImportSegmentTests() { nullableIntType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32), true); nullableDecimalType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Decimal), true); nullableBinaryType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Binary), true); nullableStringType = new EdmPrimitiveTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), true); container = ModelBuildingHelpers.BuildValidEntityContainer(); model = new EdmModel(); model.AddElement(container); this.functionIntToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType); this.functionIntToInt.AddParameter("Parameter1", this.nullableIntType); this.functionImportIntToInt = new EdmFunctionImport(this.container, "Function", this.functionIntToInt); this.functionDecimalToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType); this.functionDecimalToInt.AddParameter("Parameter1", this.nullableDecimalType); this.functionImportDecimalToInt = new EdmFunctionImport(this.container, "Function", this.functionDecimalToInt); this.functionBinaryToInt = new EdmFunction("Name.Space", "Function", this.nullableIntType); this.functionBinaryToInt.AddParameter("Parameter1", this.nullableBinaryType); this.functionImportBinaryToInt = new EdmFunctionImport(this.container, "Function", this.functionBinaryToInt); this.functionIntToString = new EdmFunction("Name.Space", "Function", this.nullableStringType); this.functionIntToString.AddParameter("Parameter1", this.nullableIntType); this.functionImportIntToString = new EdmFunctionImport(this.container, "Function", this.functionIntToString); model.AddElement(functionIntToInt); model.AddElement(functionDecimalToInt); model.AddElement(functionBinaryToInt); model.AddElement(functionIntToString); }
public void TypeIsSetCorrectly() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); segment.EdmType.Should().BeSameAs(set.EntityType()); }
public void TypeSetCorrectly() { IEdmType type = ModelBuildingHelpers.BuildValidEntityType(); TypeSegment segment = new TypeSegment(type, null); Assert.Same(type, segment.EdmType); }
public void SetIsCopiedFromPreviousSegment() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); Assert.Same(set, segment.NavigationSource); }
public void KeySetCorrectly() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); segment.Keys.Should().OnlyContain(x => x.Key == "key" && x.Value.As <string>() == "value"); }
public void TypeIsSetCorrectly() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); Assert.Same(set.EntityType(), segment.EdmType); }
public void EqualityIsCorrect() { IEdmEntityType entityType = ModelBuildingHelpers.BuildValidEntityType(); ValueSegment segment1 = new ValueSegment(entityType); ValueSegment segment2 = new ValueSegment(entityType); Assert.True(segment1.Equals(segment2)); }
public void SetIsSetCorrectly() { var set = ModelBuildingHelpers.BuildValidEntitySet(); IEdmType type = set.EntityType(); TypeSegment segment = new TypeSegment(type, set); segment.NavigationSource.Should().BeSameAs(set); }
public void TranslateWithValueSegmentReturnsThrows() { IsCollectionTranslator translator = new IsCollectionTranslator(); var segment = new ValueSegment(ModelBuildingHelpers.BuildValidEntityType()); Action translateAction = () => translator.Translate(segment); translateAction.Throws <NotImplementedException>(segment.ToString()); }
public void InequalityIsCorrect() { ValueSegment segment1 = new ValueSegment(ModelBuildingHelpers.BuildValidEntityType()); ValueSegment segment2 = new ValueSegment(ModelBuildingHelpers.BuildValidComplexType()); BatchSegment segment3 = BatchSegment.Instance; Assert.False(segment1.Equals(segment2)); Assert.False(segment1.Equals(segment3)); }
public void KeySetCorrectly() { var set = ModelBuildingHelpers.BuildValidEntitySet(); KeySegment segment = new KeySegment(Key, set.EntityType(), set); var key = Assert.Single(segment.Keys); Assert.Equal("key", key.Key); Assert.Equal("value", key.Value); }
public void TranslateWithKeySetSegmentReturnsFalse() { IsCollectionTranslator translator = new IsCollectionTranslator(); var segment = new KeySegment( new List <KeyValuePair <string, object> >(), ModelBuildingHelpers.BuildValidEntityType(), null); Assert.False(translator.Translate(segment)); }
public void OperationOverloadsWithSameNameWithoutBindingType() { var model = ModelBuildingHelpers.GetModelWithOperationOverloadsWithSameName(); var parameters = new string[] {}; IEdmOperation operation; Action resolve = () => FunctionOverloadResolver.ResolveOperationFromList("Test.Action", parameters, null, model, out operation, DefaultUriResolver); resolve.Throws <ODataException>(ODataErrorStrings.FunctionOverloadResolver_MultipleActionOverloads("Test.Action")); }
public void ModelWithMultipleOverloadedActionsShouldThrow() { var model = ModelBuildingHelpers.GetModelWithMixedActionsAndFunctionsWithSameName(); var parameters = new string[0]; IEdmOperationImport function; Action test = () => FunctionOverloadResolver.ResolveOperationImportFromList("Foo", parameters, model, out function, ODataUriResolver.Default); test.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.FunctionOverloadResolver_MultipleOperationImportOverloads("Foo")); }
public void ActionWithMultipleOverloadsForTheSameBindingParameter() { var model = ModelBuildingHelpers.GetModelWithIllegalActionOverloads(); var parameters = new string[] { }; IEdmOperationImport function; Action resolve = () => FunctionOverloadResolver.ResolveOperationImportFromList("Action", parameters, model, out function, ODataUriResolver.Default); resolve.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.FunctionOverloadResolver_MultipleActionImportOverloads("Action")); }
public void PathSelectionItemIsNotImplemented() { FakeHandler handler = new FakeHandler(); PathSelectItem item = new PathSelectItem(new ODataSelectPath() { new PropertySegment(ModelBuildingHelpers.BuildValidPrimitiveProperty()) }); Action visitPath = () => item.HandleWith(handler); visitPath.ShouldThrow <NotImplementedException>(); }
public void ExpandedNavigationPropertySelectItemIsNotImplemented() { FakeHandler handler = new FakeHandler(); ExpandedNavigationSelectItem item = new ExpandedNavigationSelectItem(new ODataExpandPath() { new NavigationPropertySegment(ModelBuildingHelpers.BuildValidNavigationProperty(), ModelBuildingHelpers.BuildValidEntitySet()) }, null, null); Action visitExpandedNavigationSelectItem = () => item.HandleWith(handler); visitExpandedNavigationSelectItem.ShouldThrow <NotImplementedException>(); }
public void ContentIdMustBeDollarNumber() { IEdmEntityType type = ModelBuildingHelpers.BuildValidEntityType(); Action createWitnInvalidContentId1 = () => new BatchReferenceSegment("stuff", type, HardCodedTestModel.GetPeopleSet()); Action createWitnInvalidContentId2 = () => new BatchReferenceSegment("1$2", type, HardCodedTestModel.GetPeopleSet()); Action createWitnInvalidContentId3 = () => new BatchReferenceSegment("$", type, HardCodedTestModel.GetPeopleSet()); Action createWitnInvalidContentId4 = () => new BatchReferenceSegment("$0a1", type, HardCodedTestModel.GetPeopleSet()); createWitnInvalidContentId1.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.BatchReferenceSegment_InvalidContentID("stuff")); createWitnInvalidContentId2.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.BatchReferenceSegment_InvalidContentID("1$2")); createWitnInvalidContentId3.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.BatchReferenceSegment_InvalidContentID("$")); createWitnInvalidContentId4.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.BatchReferenceSegment_InvalidContentID("$0a1")); }
public void ExpandedNavigationPropertiesAreImplicitlyAddedAsPathSelectionItemsIfSelectIsPopulated() { IEdmNavigationProperty navigationProperty = ModelBuildingHelpers.BuildValidNavigationProperty(); SelectExpandClause clause = new SelectExpandClause(new SelectItem[] { new PathSelectItem(new ODataSelectPath(new PropertySegment(ModelBuildingHelpers.BuildValidPrimitiveProperty()))), new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(navigationProperty, ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List <SelectItem>(), false)), }, false /*allSelected*/); SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause); clause.SelectedItems.Should().HaveCount(3) .And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath.LastSegment is NavigationPropertySegment && x.As <PathSelectItem>().SelectedPath.LastSegment.As <NavigationPropertySegment>().NavigationProperty.Name == navigationProperty.Name); }
public void RawKeyValuesMustBePopulated() { Action callWithNullRawKey = () => KeyFinder.FindAndUseKeysFromRelatedSegment( null, new List <IEdmStructuralProperty>() { ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty() }, ModelBuildingHelpers.BuildValidNavigationProperty(), new KeySegment( new List <KeyValuePair <string, object> >(), ModelBuildingHelpers.BuildValidEntityType(), null)); Assert.Throws <ArgumentNullException>("rawKeyValuesFromUri", callWithNullRawKey); }
public void RawKeyValuesMustBePopulated() { Action callWithNullRawKey = () => KeyFinder.FindAndUseKeysFromRelatedSegment( null, new List <IEdmStructuralProperty>() { ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty() }, ModelBuildingHelpers.BuildValidNavigationProperty(), new KeySegment( new List <KeyValuePair <string, object> >(), ModelBuildingHelpers.BuildValidEntityType(), null)); callWithNullRawKey.ShouldThrow <ArgumentNullException>().WithMessage("rawKeyValues", ComparisonMode.EquivalentSubstring); }
public void ExpandedNavigationPropertiesAreImplicitlyAddedAsPathSelectionItemsIfSelectIsPopulated() { IEdmNavigationProperty navigationProperty = ModelBuildingHelpers.BuildValidNavigationProperty(); IEdmStructuralProperty structuralProperty = ModelBuildingHelpers.BuildValidPrimitiveProperty(); SelectExpandClause clause = new SelectExpandClause(new SelectItem[] { new PathSelectItem(new ODataSelectPath(new PropertySegment(structuralProperty))), new ExpandedNavigationSelectItem(new ODataExpandPath(new NavigationPropertySegment(navigationProperty, ModelBuildingHelpers.BuildValidEntitySet())), ModelBuildingHelpers.BuildValidEntitySet(), new SelectExpandClause(new List <SelectItem>(), false)), }, false /*allSelected*/); SelectExpandClauseFinisher.AddExplicitNavPropLinksWhereNecessary(clause); Assert.Equal(2, clause.SelectedItems.Count()); var pathSelectItem = Assert.IsType <PathSelectItem>(Assert.Single(clause.SelectedItems, x => x is PathSelectItem)); var propertySegment = Assert.IsType <PropertySegment>(pathSelectItem.SelectedPath.LastSegment); Assert.Equal(structuralProperty.Name, propertySegment.Property.Name); }
public void RawKeyWithMoreThanOnePositionalValueIsUnchanged() { SegmentArgumentParser key; SegmentArgumentParser.TryParseKeysFromUri("0,1", out key, false); var newKey = KeyFinder.FindAndUseKeysFromRelatedSegment( key, new List <IEdmStructuralProperty>() { ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty() }, ModelBuildingHelpers.BuildValidNavigationProperty(), new KeySegment( new List <KeyValuePair <string, object> >(), ModelBuildingHelpers.BuildValidEntityType(), null)); newKey.Should().Be(key); }
public void CurrentNavigaitionPropertyMustBePopulated() { SegmentArgumentParser key; SegmentArgumentParser.TryParseKeysFromUri("0,1", out key, false); Action callWithNullNavProp = () => KeyFinder.FindAndUseKeysFromRelatedSegment( key, new List <IEdmStructuralProperty>() { ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty(), ModelBuildingHelpers.BuildValidPrimitiveProperty() }, null, new KeySegment( new List <KeyValuePair <string, object> >(), ModelBuildingHelpers.BuildValidEntityType(), null)); callWithNullNavProp.ShouldThrow <ArgumentNullException>().WithMessage("currentNavigationProperty", ComparisonMode.EquivalentSubstring); }
public void TopLevelEntitySetCanBeNull() { SelectExpandBinder binder = new SelectExpandBinder(this.V4configuration, ModelBuildingHelpers.BuildValidEntityType(), null); binder.NavigationSource.Should().BeNull(); }
public void CollectionNavigationNotImplemented() { FakeVisitor visitor = new FakeVisitor(); Action visitCollectionNavigationNode = () => visitor.Visit(new CollectionNavigationNode(ModelBuildingHelpers.BuildCollectionNavigationProperty(), HardCodedTestModel.GetPeopleSet())); visitCollectionNavigationNode.ShouldThrow <NotImplementedException>(); }