Пример #1
0
        internal static void InlineEntryInstanceAnnotationTest(string payload, string contentType, bool isResponse, bool shouldReadAndValidateCustomInstanceAnnotations = true, bool odataSimplified = false)
        {
            ODataEntry entryFromReader = null;
            int        depth           = 0;

            using (var messageReader = CreateODataMessageReader(payload, contentType, isResponse, shouldReadAndValidateCustomInstanceAnnotations, odataSimplified))
            {
                var odataReader = messageReader.CreateODataEntryReader(EntitySet, EntityType);

                while (odataReader.Read())
                {
                    switch (odataReader.State)
                    {
                    case ODataReaderState.NavigationLinkStart:
                        depth++;
                        break;

                    case ODataReaderState.NavigationLinkEnd:
                        depth--;
                        break;

                    case ODataReaderState.EntryStart:
                        if (depth == 1)
                        {
                            entryFromReader = (ODataEntry)odataReader.Item;
                            ValidateContainsAllExpectedInstanceAnnotationsBeforeStateChange(entryFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                        }
                        else
                        {
                            ((ODataEntry)odataReader.Item).InstanceAnnotations.Should().HaveCount(0);
                        }

                        break;

                    case ODataReaderState.EntryEnd:
                        if (depth == 1)
                        {
                            entryFromReader.Should().NotBeNull();
                            ValidateContainsAllExpectedInstanceAnnotations(entryFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                        }
                        else
                        {
                            ((ODataEntry)odataReader.Item).InstanceAnnotations.Should().HaveCount(0);
                        }

                        break;
                    }
                }
            }

            entryFromReader.Should().NotBeNull();
            ValidateContainsAllExpectedInstanceAnnotations(entryFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
        }
Пример #2
0
        internal static void TopLevelEntryInstanceAnnotationTest(string payload, string contentType, bool isSingleton, bool isResponse, bool shouldReadAndValidateCustomInstanceAnnotations = true)
        {
            ODataEntry entryFromReader = null;

            using (var messageReader = CreateODataMessageReader(payload, contentType, isResponse, shouldReadAndValidateCustomInstanceAnnotations))
            {
                IEdmNavigationSource navigationSource;
                if (isSingleton)
                {
                    navigationSource = Singleton;
                }
                else
                {
                    navigationSource = EntitySet;
                }

                var odataReader = messageReader.CreateODataEntryReader(navigationSource, EntityType);

                while (odataReader.Read())
                {
                    switch (odataReader.State)
                    {
                    case ODataReaderState.EntryStart:
                        entryFromReader = (ODataEntry)odataReader.Item;
                        ValidateContainsAllExpectedInstanceAnnotationsBeforeStateChange(entryFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                        break;

                    case ODataReaderState.EntryEnd:
                        entryFromReader.Should().NotBeNull();
                        ValidateContainsAllExpectedInstanceAnnotations(entryFromReader.InstanceAnnotations, shouldReadAndValidateCustomInstanceAnnotations);
                        break;
                    }
                }
            }

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