public void WriteEntryWithWrongSerializationInfo()
        {
            foreach (var mimeType in this.testMimeTypes)
            {
                var settings = new ODataMessageWriterSettings();
                settings.ODataUri = new ODataUri()
                {
                    ServiceRoot = this.ServiceUri
                };

                // wrong EntitySetName for entry
                var responseMessageWithoutModel = new StreamResponseMessage(new MemoryStream());
                responseMessageWithoutModel.SetHeader("Content-Type", mimeType);
                using (var messageWriter = new ODataMessageWriter(responseMessageWithoutModel, settings))
                {
                    var odataWriter = messageWriter.CreateODataResourceWriter();
                    var entry       = this.CreatePersonEntryWithoutSerializationInfo();

                    entry.SetSerializationInfo(new ODataResourceSerializationInfo()
                    {
                        NavigationSourceName = "Parsen", NavigationSourceEntityTypeName = NameSpace + "Person"
                    });
                    odataWriter.WriteStart(entry);
                    odataWriter.WriteEnd();
                    var result = WritePayloadHelper.ReadStreamContent(responseMessageWithoutModel.GetStream());
                    Assert.IsTrue(result.Contains("\"PersonId\":-5"));
                    if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
                    {
                        // no metadata does not write odata.metadata
                        Assert.IsTrue(result.Contains("$metadata#Parsen/$entity"));
                        Assert.IsTrue(result.Contains("Person(-5)\",\"PersonId\":-5"));
                    }
                    else
                    {
                        Assert.IsFalse(result.Contains("Person(-5)\",\"PersonId\":-5"));
                    }
                }

                // wrong EntitySetName for feed
                responseMessageWithoutModel = new StreamResponseMessage(new MemoryStream());
                responseMessageWithoutModel.SetHeader("Content-Type", mimeType);
                using (var messageWriter = new ODataMessageWriter(responseMessageWithoutModel, settings))
                {
                    var odataWriter = messageWriter.CreateODataResourceSetWriter();

                    var feed = this.CreatePersonFeed();
                    feed.SetSerializationInfo(new ODataResourceSerializationInfo()
                    {
                        NavigationSourceName = "Parsen", NavigationSourceEntityTypeName = NameSpace + "Person"
                    });
                    var entry = this.CreatePersonEntryWithoutSerializationInfo();
                    odataWriter.WriteStart(feed);
                    odataWriter.WriteStart(entry);
                    odataWriter.WriteEnd();
                    odataWriter.WriteEnd();
                    var result = WritePayloadHelper.ReadStreamContent(responseMessageWithoutModel.GetStream());
                    Assert.IsTrue(result.Contains("\"PersonId\":-5"));
                    if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
                    {
                        // no metadata does not write odata.metadata
                        Assert.IsTrue(result.Contains("$metadata#Parsen\""));
                        Assert.IsTrue(result.Contains("Person(-5)\",\"PersonId\":-5"));
                    }
                    else
                    {
                        Assert.IsFalse(result.Contains("Person(-5)\",\"PersonId\":-5"));
                    }
                }

                // wrong complex collection type name
                responseMessageWithoutModel = new StreamResponseMessage(new MemoryStream());
                responseMessageWithoutModel.SetHeader("Content-Type", mimeType);
                using (var messageWriter = new ODataMessageWriter(responseMessageWithoutModel, settings))
                {
                    var odataWriter       = messageWriter.CreateODataResourceSetWriter();
                    var complexCollection = new ODataResourceSetWrapper()
                    {
                        ResourceSet = new ODataResourceSet(),
                        Resources   = new List <ODataResourceWrapper>()
                        {
                            WritePayloadHelper.CreatePrimaryContactODataWrapper()
                        }
                    };

                    complexCollection.ResourceSet.SetSerializationInfo(new ODataResourceSerializationInfo()
                    {
                        ExpectedTypeName = NameSpace + "ContactDETAIL"
                    });
                    ODataWriterHelper.WriteResourceSet(odataWriter, complexCollection);
                    var result = WritePayloadHelper.ReadStreamContent(responseMessageWithoutModel.GetStream());
                    if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
                    {
                        // [{"@odata.type":"#Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails","*****@*****.**":"#Collection(String)"...
                        Assert.IsTrue(result.Contains("\"value\":[{\"@odata.type\":\"#Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails\",\"EmailBag"));

                        // no metadata does not write odata.metadata
                        Assert.IsTrue(result.Contains("$metadata#Collection(" + NameSpace + "ContactDETAIL)"));
                    }
                    else
                    {
                        Assert.IsFalse(result.Contains("\"@odata.type\":\"#Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails\""));
                    }
                }

                // The following two cases of wrong reference link info is no longer active. The ODataEntityReferenceLinkSerializationInfo is ignored when writer writes the payload.
                // Consider removing them.

                // wrong reference link info
                responseMessageWithoutModel = new StreamResponseMessage(new MemoryStream());
                responseMessageWithoutModel.SetHeader("Content-Type", mimeType);
                using (var messageWriter = new ODataMessageWriter(responseMessageWithoutModel, settings))
                {
                    var link = new ODataEntityReferenceLink()
                    {
                        Url = new Uri(this.ServiceUri + "Order(-10)")
                    };
                    messageWriter.WriteEntityReferenceLink(link);
                    var result = WritePayloadHelper.ReadStreamContent(responseMessageWithoutModel.GetStream());
                    Assert.IsTrue(result.Contains(this.ServiceUri + "Order(-10)"));
                    if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
                    {
                        // no metadata does not write odata.context
                        Assert.IsTrue(result.Contains("$metadata#$ref"));
                    }
                }

                // wrong reference links info
                responseMessageWithoutModel = new StreamResponseMessage(new MemoryStream());
                responseMessageWithoutModel.SetHeader("Content-Type", mimeType);
                using (var messageWriter = new ODataMessageWriter(responseMessageWithoutModel, settings))
                {
                    var links = new ODataEntityReferenceLinks()
                    {
                        Links = new[]
                        {
                            new ODataEntityReferenceLink()
                            {
                                Url = new Uri(this.ServiceUri + "Order(-10)")
                            }
                        },
                    };

                    messageWriter.WriteEntityReferenceLinks(links);
                    var result = WritePayloadHelper.ReadStreamContent(responseMessageWithoutModel.GetStream());
                    Assert.IsTrue(result.Contains(this.ServiceUri + "Order(-10)"));
                    if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
                    {
                        // no metadata does not write odata.metadata
                        Assert.IsTrue(result.Contains("$metadata#Collection($ref)"));
                    }
                }
            }
        }