private string WriteAndVerifyOrderFeed(ODataMessageWriterSettings settings, string mimeType, bool hasModel) { // create a feed with two entries var orderFeed = new ODataFeed() { NextPageLink = new Uri(this.ServiceUri + "Order?$skiptoken=-9"), Count = 9999 }; if (mimeType == MimeTypes.ApplicationAtomXml) { orderFeed.Id = new Uri(this.ServiceUri + "Order"); } if (!hasModel) { orderFeed.SetSerializationInfo(new ODataFeedAndEntrySerializationInfo() { NavigationSourceName = "Order", NavigationSourceEntityTypeName = NameSpace + "Order" }); } var orderEntry1 = WritePayloadHelper.CreateOrderEntry1NoMetadata(hasModel); Dictionary <string, object> expectedOrderObject1 = WritePayloadHelper.ComputeExpectedFullMetadataEntryObject(WritePayloadHelper.OrderType, "Order(-10)", orderEntry1, hasModel); var orderEntry2 = WritePayloadHelper.CreateOrderEntry2NoMetadata(hasModel); Dictionary <string, object> expectedOrderObject2 = WritePayloadHelper.ComputeExpectedFullMetadataEntryObject(WritePayloadHelper.OrderType, "Order(-9)", orderEntry2, hasModel); var orderEntry2Navigation = WritePayloadHelper.AddOrderEntryCustomNavigation(orderEntry2, expectedOrderObject2, hasModel); // write the response message and read using ODL reader var responseMessage = new StreamResponseMessage(new MemoryStream()); responseMessage.SetHeader("Content-Type", mimeType); string result = string.Empty; using (var messageWriter = this.CreateODataMessageWriter(responseMessage, settings, hasModel)) { var odataWriter = this.CreateODataFeedWriter(messageWriter, WritePayloadHelper.OrderSet, WritePayloadHelper.OrderType, hasModel); odataWriter.WriteStart(orderFeed); odataWriter.WriteStart(orderEntry1); odataWriter.WriteEnd(); odataWriter.WriteStart(orderEntry2); odataWriter.WriteStart(orderEntry2Navigation); odataWriter.WriteEnd(); odataWriter.WriteEnd(); // Finish writing the feed. odataWriter.WriteEnd(); result = this.ReadFeedEntryMessage(true, responseMessage, mimeType, WritePayloadHelper.OrderSet, WritePayloadHelper.OrderType); } if (mimeType != MimeTypes.ApplicationAtomXml) { JavaScriptSerializer jScriptSerializer = new JavaScriptSerializer(); Dictionary <string, object> resultObject = jScriptSerializer.DeserializeObject(result) as Dictionary <string, object>; Assert.AreEqual(this.ServiceUri + "Order?$skiptoken=-9", resultObject.Single(e => e.Key == (JsonLightConstants.ODataNextLinkAnnotationName)).Value, "Feed next link"); Assert.AreEqual(9999, resultObject.Single(e => e.Key == (JsonLightConstants.ODataCountAnnotationName)).Value, "Feed count"); resultObject.Remove(JsonLightConstants.ODataNextLinkAnnotationName); resultObject.Remove(JsonLightConstants.ODataCountAnnotationName); VerifyODataContextAnnotation(this.ServiceUri + "$metadata#Order", resultObject, mimeType); VerifyEntry(expectedOrderObject1, orderEntry1, new ODataNavigationLink[] { }, new ODataProperty[] { }, (resultObject.Last().Value as object[]).First() as Dictionary <string, object>, mimeType, settings.AutoComputePayloadMetadataInJson); VerifyEntry(expectedOrderObject2, orderEntry2, new ODataNavigationLink[] { orderEntry2Navigation }, new ODataProperty[] { }, (resultObject.Last().Value as object[]).Last() as Dictionary <string, object>, mimeType, settings.AutoComputePayloadMetadataInJson); } return(result); }