private string WriteAndVerifyExpandedCustomerEntry(StreamResponseMessage responseMessage, ODataWriter odataWriter, bool hasModel, string mimeType) { ODataEntry customerEntry = WritePayloadHelper.CreateCustomerEntry(hasModel); odataWriter.WriteStart(customerEntry); // write non-expanded navigations foreach (var navigation in WritePayloadHelper.CreateCustomerNavigationLinks()) { odataWriter.WriteStart(navigation); odataWriter.WriteEnd(); } // write expanded navigation var expandedNavigation = new ODataNavigationLink() { Name = "Logins", IsCollection = true, Url = new Uri(this.ServiceUri + "Customer(-9)/Logins") }; odataWriter.WriteStart(expandedNavigation); var loginFeed = new ODataFeed() { Id = new Uri(this.ServiceUri + "Customer(-9)/Logins") }; if (!hasModel) { loginFeed.SetSerializationInfo(new ODataFeedAndEntrySerializationInfo() { NavigationSourceName = "Login", NavigationSourceEntityTypeName = NameSpace + "Login" }); } odataWriter.WriteStart(loginFeed); var loginEntry = WritePayloadHelper.CreateLoginEntry(hasModel); odataWriter.WriteStart(loginEntry); foreach (var navigation in WritePayloadHelper.CreateLoginNavigationLinks()) { odataWriter.WriteStart(navigation); odataWriter.WriteEnd(); } // Finish writing loginEntry. odataWriter.WriteEnd(); // Finish writing the loginFeed. odataWriter.WriteEnd(); // Finish writing expandedNavigation. odataWriter.WriteEnd(); // Finish writing customerEntry. odataWriter.WriteEnd(); // Some very basic verification for the payload. bool verifyFeedCalled = false; int verifyEntryCalled = 0; bool verifyNavigationCalled = false; Action <ODataFeed> verifyFeed = (feed) => { verifyFeedCalled = true; }; Action <ODataEntry> verifyEntry = (entry) => { if (entry.TypeName.Contains("Customer")) { Assert.AreEqual(7, entry.Properties.Count()); } if (entry.TypeName.Contains("Login")) { Assert.AreEqual(2, entry.Properties.Count()); } verifyEntryCalled++; }; Action <ODataNavigationLink> verifyNavigation = (navigation) => { Assert.IsNotNull(navigation.Name); verifyNavigationCalled = true; }; Stream stream = responseMessage.GetStream(); if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata)) { stream.Seek(0, SeekOrigin.Begin); WritePayloadHelper.ReadAndVerifyFeedEntryMessage(false, responseMessage, WritePayloadHelper.CustomerSet, WritePayloadHelper.CustomerType, verifyFeed, verifyEntry, verifyNavigation); Assert.IsTrue(verifyFeedCalled && verifyEntryCalled == 2 && verifyNavigationCalled, "Verification action not called."); } return(WritePayloadHelper.ReadStreamContent(stream)); }