예제 #1
0
        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));
        }
예제 #2
0
        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();
        }
예제 #3
0
 public void UrlConventionShouldBeKeysAsSegmentsIfKnobIsFlippedAndHeaderIsCorrectValue()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, KeysAsSegmentsHeaderValue).GenerateKeyAsSegment.Should().BeTrue();
 }
예제 #4
0
        public void UrlConventionShouldShouldThrowIfKnobIsFlippedAndHeaderIsWrongValue()
        {
            Action callOverload = () => UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, WrongHeader);

            callOverload.ShouldThrow <DataServiceException>().WithMessage(Microsoft.OData.Service.Strings.UrlConvention_BadRequestIfUnknown("wrong", "DataServiceUrlConventions", "Default", "KeyAsSegment"));
        }
예제 #5
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsMissing()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, NoHeader).GenerateKeyAsSegment.Should().BeFalse();
 }
예제 #6
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsDefault()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, DefaultUrlConventionHeaderValue).GenerateKeyAsSegment.Should().BeFalse();
 }
예제 #7
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsNotFlipped()
 {
     UrlConvention.CreateFromUserInput(this.defaultBehavior, ShouldNotBeCalled).GenerateKeyAsSegment.Should().BeFalse();
 }