private static IEnumerable <IEdmVocabularyAnnotation> GetMetadataAnnotations(DataServiceBehavior dataServiceBehavior, out EdmEntityContainer container) { container = new EdmEntityContainer("Fake", "Container"); var primaryModel = new EdmModel(); primaryModel.AddElement(container); return(UrlConvention.BuildMetadataAnnotations(dataServiceBehavior, primaryModel)); }
public void UrlConventionIntegrationTest() { var host = new DataServiceHost2Simulator { RequestHeaders = new WebHeaderCollection { { UrlConventionsConstants.UrlConventionHeaderName, "KeyAsSegment" } }, }; var service = new DataServiceSimulator { Configuration = new DataServiceConfiguration(new DataServiceProviderSimulator()), OperationContext = new DataServiceOperationContext(host) }; service.OperationContext.InitializeAndCacheHeaders(service); service.Configuration.DataServiceBehavior.UrlConventions = DataServiceUrlConventions.KeyAsSegment; UrlConvention.Create(service).GenerateKeyAsSegment.Should().BeTrue(); }
public void UrlConventionShouldBeKeysAsSegmentsIfKnobIsFlippedAndHeaderIsCorrectValue() { UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, KeysAsSegmentsHeaderValue).GenerateKeyAsSegment.Should().BeTrue(); }
public void UrlConventionShouldShouldThrowIfKnobIsFlippedAndHeaderIsWrongValue() { Action callOverload = () => UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, WrongHeader); callOverload.ShouldThrow <DataServiceException>().WithMessage(Microsoft.OData.Service.Strings.UrlConvention_BadRequestIfUnknown("wrong", "DataServiceUrlConventions", "Default", "KeyAsSegment")); }
public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsMissing() { UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, NoHeader).GenerateKeyAsSegment.Should().BeFalse(); }
public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsDefault() { UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, DefaultUrlConventionHeaderValue).GenerateKeyAsSegment.Should().BeFalse(); }
public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsNotFlipped() { UrlConvention.CreateFromUserInput(this.defaultBehavior, ShouldNotBeCalled).GenerateKeyAsSegment.Should().BeFalse(); }