/// <summary> /// Constructs an instance of <see cref="ODataFeedAndEntryTypeContext"/>. /// </summary> /// <param name="navigationSource">The navigation source of the feed or entry.</param> /// <param name="navigationSourceEntityType">The entity type of the navigation source.</param> /// <param name="expectedEntityType">The expected entity type of the feed or entry.</param> /// <param name="model">The Edm model instance to use.</param> internal ODataFeedAndEntryTypeContextWithModel(IEdmNavigationSource navigationSource, IEdmEntityType navigationSourceEntityType, IEdmEntityType expectedEntityType, IEdmModel model) : base(/*throwIfMissingTypeInfo*/ false) { Debug.Assert(model != null, "model != null"); Debug.Assert(navigationSource != null, "navigationSource != null"); Debug.Assert(navigationSourceEntityType != null, "navigationSourceEntityType != null"); Debug.Assert(expectedEntityType != null, "expectedEntityType != null"); this.navigationSource = navigationSource; this.navigationSourceEntityType = navigationSourceEntityType; this.expectedEntityType = expectedEntityType; this.model = model; IEdmContainedEntitySet containedEntitySet = navigationSource as IEdmContainedEntitySet; if (containedEntitySet != null) { if (containedEntitySet.NavigationProperty.Type.TypeKind() == EdmTypeKind.Collection) { this.isFromCollection = true; } } this.navigationSourceName = this.navigationSource.Name; this.isMediaLinkEntry = this.expectedEntityType.HasStream; this.lazyUrlConvention = new SimpleLazy <UrlConvention>(() => UrlConvention.ForModel(this.model)); }
public void UrlConventionFromAnnotationShouldReturnDefaultIfAnnotationHasWrongValue() { var container = new EdmEntityContainer("Fake", "Container"); var model = new EdmModel(); model.AddElement(container); model.AddVocabularyAnnotation(new EdmAnnotation(container, UrlConventionsConstants.ConventionTerm, new EdmStringConstant("fake"))); UrlConvention.ForModel(model).GenerateKeyAsSegment.Should().BeFalse(); }
public void UrlConventionFromAnnotationShouldReturnKeyAsSegmentIfAnnotationFound() { var container = new EdmEntityContainer("Fake", "Container"); var model = new EdmModel(); model.AddElement(container); model.AddVocabularyAnnotation(new EdmAnnotation(container, UrlConventionsConstants.ConventionTerm, UrlConventionsConstants.KeyAsSegmentAnnotationValue)); UrlConvention.ForModel(model).GenerateKeyAsSegment.Should().BeTrue(); }
public void UrlConventionFromAnnotationShouldReturnDefaultIfAnnotationMissing() { var container = new EdmEntityContainer("Fake", "Container"); var model = new EdmModel(); model.AddElement(container); model.AddVocabularyAnnotation(new EdmAnnotation(container, new EdmTerm("Fake", "Fake", EdmPrimitiveTypeKind.Stream), EdmNullExpression.Instance)); UrlConvention.ForModel(model).GenerateKeyAsSegment.Should().BeFalse(); }