コード例 #1
0
        internal static void TopLevelFeedInstanceAnnotationTest(string feedPayload, string contentType, bool isResponse, bool shouldReadAndValidateCustomInstanceAnnotations = true, bool enableReadingODataAnnotationWithoutPrefix = false)
        {
            ODataResourceSet feedFromReader = null;

            using (var messageReader = CreateODataMessageReader(feedPayload, contentType, isResponse, shouldReadAndValidateCustomInstanceAnnotations, enableReadingODataAnnotationWithoutPrefix))
            {
                var odataReader = messageReader.CreateODataResourceSetReader(EntitySet, EntityType);

                while (odataReader.Read())
                {
                    switch (odataReader.State)
                    {
                    case ODataReaderState.ResourceSetStart:
                        feedFromReader = (ODataResourceSet)odataReader.Item;
                        if (IsStreaming(contentType))
                        {
                            if (shouldReadAndValidateCustomInstanceAnnotations)
                            {
                                ValidateContainsAllExpectedInstanceAnnotationsBeforeStateChange(feedFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                            }
                            else
                            {
                                feedFromReader.InstanceAnnotations.Count.Should().Be(0);
                            }
                        }
                        else
                        {
                            ValidateContainsAllExpectedInstanceAnnotations(feedFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                        }
                        break;

                    case ODataReaderState.ResourceSetEnd:
                        feedFromReader.Should().NotBeNull();
                        ValidateContainsAllExpectedInstanceAnnotations(feedFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);

                        break;
                    }
                }
            }

            feedFromReader.Should().NotBeNull();
            ValidateContainsAllExpectedInstanceAnnotations(feedFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
        }