Ejemplo n.º 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));
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 3
0
 public void UrlConventionShouldBeKeysAsSegmentsIfKnobIsFlippedAndHeaderIsCorrectValue()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, KeysAsSegmentsHeaderValue).GenerateKeyAsSegment.Should().BeTrue();
 }
Ejemplo n.º 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"));
        }
Ejemplo n.º 5
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsMissing()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, NoHeader).GenerateKeyAsSegment.Should().BeFalse();
 }
Ejemplo n.º 6
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsFlippedButHeaderIsDefault()
 {
     UrlConvention.CreateFromUserInput(this.behaviorWithKeysAsSegments, DefaultUrlConventionHeaderValue).GenerateKeyAsSegment.Should().BeFalse();
 }
Ejemplo n.º 7
0
 public void UrlConventionShouldNotBeKeysAsSegmentsIfKnobIsNotFlipped()
 {
     UrlConvention.CreateFromUserInput(this.defaultBehavior, ShouldNotBeCalled).GenerateKeyAsSegment.Should().BeFalse();
 }