Esempio n. 1
0
        /// <summary>
        /// Generates various payloads with different link properties set to the specified cross reference value.
        /// </summary>
        /// <param name="crossReferenceLink">The cross reference link values to set on each payload.</param>
        /// <param name="testConfiguration">The test configuration to use.</param>
        /// <returns>The payloads.</returns>
        private static IEnumerable <ODataPayloadElement> GeneratePayloadElementsWithCrossReferenceLinks(string crossReferenceLink, ReaderTestConfiguration testConfiguration)
        {
            List <ODataPayloadElement> payloadElements = new List <ODataPayloadElement>();

            // Entry with edit link
            payloadElements.Add(PayloadBuilder.Entity("TestModel.Address").PrimitiveProperty("Zip", 12345).WithEditLink(crossReferenceLink));

            // Entry with self link
            payloadElements.Add(PayloadBuilder.Entity("TestModel.Address").PrimitiveProperty("Zip", 98765).WithSelfLink(crossReferenceLink));

            // Entry with deferred navprop
            payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink)));

            // Entry with expanded navprop
            payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").ExpandedNavigationProperty("PoliceStation", PayloadBuilder.Entity("TestModel.OfficeType").PrimitiveProperty("Id", 0), crossReferenceLink));

            if (!testConfiguration.IsRequest)
            {
                // Entry with deferred navprop with association link
                payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("DOL", PayloadBuilder.DeferredLink("http://odata.org"), PayloadBuilder.DeferredLink(crossReferenceLink)));

                // Entry with expanded navprop with association link
                payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").NavigationProperty(
                                        PayloadBuilder.ExpandedNavigationProperty("PoliceStation", PayloadBuilder.Entity("TestModel.OfficeType").PrimitiveProperty("Id", 0), "http://odata.org", crossReferenceLink)));

                // Entry with stream property with read link
                payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").StreamProperty("Skyline", crossReferenceLink));

                // Entry with stream property with edit link
                payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").StreamProperty("Skyline", null, crossReferenceLink));

                // Feed with multiple entries referencing same link
                payloadElements.Add(PayloadBuilder.EntitySet(
                                        new[]
                {
                    PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink)),
                    PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink)),
                }));
            }

            return(payloadElements);
        }