public void ShouldReadEntityReferenceNextLinkAnnotationValue() { string payload = @"{ ""@odata.context"":""http://odata.org/test/$metadata#Collection($ref)"", ""@odata.nextLink"":""http://odata.org/nextpage"", ""@TestNamespace.name"":321, ""@custom.name"":654, ""value"":[] }"; ODataJsonLightEntityReferenceLinkDeserializer deserializer = this.CreateJsonLightEntryAndFeedDeserializer(payload); ODataEntityReferenceLinks links = deserializer.ReadEntityReferenceLinks(); Assert.Equal(new Uri("http://odata.org/nextpage"), links.NextPageLink); }
public void ReadEntityReferenceLinks_ThrowsExceptionForInvalidPropertyAnnotationInEntityReferenceLinks() { var payload = "{\"@odata.context\":\"http://tempuri.org/$metadata#Collection($ref)\"," + "\"[email protected]\":\"foobar\"}"; using (var jsonInputContext = CreateJsonLightInputContext( payload, this.model)) { var jsonLightEntityReferenceLinkDeserializer = new ODataJsonLightEntityReferenceLinkDeserializer(jsonInputContext); var exception = Assert.Throws <ODataException>( () => jsonLightEntityReferenceLinkDeserializer.ReadEntityReferenceLinks()); Assert.Equal( ODataErrorStrings.ODataJsonLightEntityReferenceLinkDeserializer_InvalidPropertyAnnotationInEntityReferenceLinks("value"), exception.Message); } }
public void ShouldReadEntityReferenceCountAnnotationValue() { string payload = @"{ ""@odata.count"":2, ""@odata.context"":""http://odata.org/test/$metadata#Collection($ref)"", ""@TestNamespace.name"":321, ""@custom.name"":654, ""value"":[ {""@odata.id"":""http://host/Customers(1)"",""@Is.New"":true}, {""@odata.id"":""http://host/Customers(2)"",""@TestNamespace.unknown"":123,""@custom.annotation"":456} ] }"; ODataJsonLightEntityReferenceLinkDeserializer deserializer = this.CreateJsonLightEntryAndFeedDeserializer(payload); ODataEntityReferenceLinks links = deserializer.ReadEntityReferenceLinks(); Assert.Equal(2, links.Count); }