Ejemplo n.º 1
0
        public void OmitOperations()
        {
            var resource = new ODataResource();
            ODataMessageWriterSettings settings = new ODataMessageWriterSettings();

            settings.MetadataSelector = new TestMetadataSelector();

            ODataResourceMetadataBuilder resourceMetadataBuilder = fullMetadataLevel.CreateResourceMetadataBuilder(
                resource,
                personTypeContext,
                null,
                HardCodedTestModel.GetPersonType(),
                new SelectedPropertiesNode(SelectedPropertiesNode.SelectionType.EntireSubtree),
                /*isResponse*/ true,
                /*keyAsSegment*/ false,
                /*requestUri*/ null,
                /*settings*/ settings);

            fullMetadataLevel.InjectMetadataBuilder(resource, resourceMetadataBuilder);
            var function = new ODataFunction {
                Metadata = new Uri(MetadataDocumentUri, "#function1"),
            };
            var action = new ODataAction {
                Metadata = new Uri(MetadataDocumentUri, "#action2")
            };

            resource.AddFunction(function);
            resource.AddAction(action);

            resource.MetadataBuilder.Should().BeSameAs(resourceMetadataBuilder);

            //metadataselector only allows for two HasHat functions to be written as metadata
            Assert.True(resource.Functions.Count() == 3);
            Assert.True(resource.Actions.Count() == 1);
        }
Ejemplo n.º 2
0
 public void FullMetadataLevelShouldReturnODataConventionalEntityMetadataBuilder()
 {
     testSubject.CreateResourceMetadataBuilder(
         new ODataResource(),
         new TestFeedAndEntryTypeContext(),
         new ODataResourceSerializationInfo(),
         /*actualEntityType*/ null,
         SelectedPropertiesNode.EntireSubtree,
         /*isResponse*/ true,
         /*keyAsSegment*/ false,
         /*requestUri*/ null).Should().BeAssignableTo <ODataConventionalResourceMetadataBuilder>();
 }
Ejemplo n.º 3
0
        public void FullMetadataLevelShouldReturnODataConventionalEntityMetadataBuilder()
        {
            var builder = testSubject.CreateResourceMetadataBuilder(
                new ODataResource(),
                new TestFeedAndEntryTypeContext(),
                new ODataResourceSerializationInfo(),
                /*actualEntityType*/ null,
                new SelectedPropertiesNode(SelectedPropertiesNode.SelectionType.EntireSubtree),
                /*isResponse*/ true,
                /*keyAsSegment*/ false,
                /*requestUri*/ null,
                /*settings*/ null);

            Assert.True(typeof(ODataConventionalResourceMetadataBuilder).IsAssignableFrom(builder.GetType()));
        }
Ejemplo n.º 4
0
        public void FullMetadataLevelCreateMetadataBuilderWithoutMetadataDocumentUriShouldThrow()
        {
            var metadataLevelWithoutMetadataDocumentUri = new JsonFullMetadataLevel(/*metadataDocumentUri*/ null, Model);

            Action test = () => metadataLevelWithoutMetadataDocumentUri
                          .CreateResourceMetadataBuilder(
                new ODataResource(),
                new TestFeedAndEntryTypeContext(),
                new ODataResourceSerializationInfo(),
                /*actualEntityType*/ null,
                SelectedPropertiesNode.EntireSubtree,
                /*isResponse*/ true,
                /*keyAsSegment*/ false,
                /*requestUri*/ null);

            test.ShouldThrow <ODataException>().WithMessage(ODataErrorStrings.ODataOutputContext_MetadataDocumentUriMissing);
        }