public void DeserializeList_EmptyResponseWithTopLevelLinks_CanDeserialize()
        {
            // Arrange
            var content = new Document
            {
                Links = new TopLevelLinks
                {
                    Self = _linkValues["self"],
                    Next = _linkValues["next"],
                    Last = _linkValues["last"]
                },
                Data = new List <ResourceObject>()
            };

            string body = JsonConvert.SerializeObject(content);

            // Act
            ManyResponse <TestResource> result = _deserializer.DeserializeMany <TestResource>(body);

            // Assert
            Assert.Empty(result.Data);
            Assert.NotNull(result.Links);
            TopLevelLinks links = result.Links;

            Assert.Equal(_linkValues["self"], links.Self);
            Assert.Equal(_linkValues["next"], links.Next);
            Assert.Equal(_linkValues["last"], links.Last);
        }
        public void DeserializeList_DeeplyNestedIncluded_CanDeserialize()
        {
            // Arrange
            var content = new Document
            {
                Data = new List <ResourceObject>
                {
                    CreateDocumentWithRelationships("multiPrincipals").SingleData
                }
            };

            content.ManyData[0].Relationships.Add("multi", CreateRelationshipData("multiPrincipals"));
            const string includedAttributeValue             = "multi member content";
            const string nestedIncludedAttributeValue       = "nested include member content";
            const string deeplyNestedIncludedAttributeValue = "deeply nested member content";

            content.Included = new List <ResourceObject>
            {
                new ResourceObject
                {
                    Type       = "multiPrincipals",
                    Id         = "10",
                    Attributes = new Dictionary <string, object>
                    {
                        ["attributeMember"] = includedAttributeValue
                    },
                    Relationships = new Dictionary <string, RelationshipEntry>
                    {
                        ["populatedToManies"] = CreateRelationshipData("oneToManyDependents", true)
                    }
                },
                new ResourceObject
                {
                    Type       = "oneToManyDependents",
                    Id         = "10",
                    Attributes = new Dictionary <string, object>
                    {
                        ["attributeMember"] = nestedIncludedAttributeValue
                    },
                    Relationships = new Dictionary <string, RelationshipEntry>
                    {
                        ["principal"] = CreateRelationshipData("oneToManyPrincipals")
                    }
                },
                new ResourceObject
                {
                    Type       = "oneToManyPrincipals",
                    Id         = "10",
                    Attributes = new Dictionary <string, object>
                    {
                        ["attributeMember"] = deeplyNestedIncludedAttributeValue
                    }
                }
            };

            string body = JsonConvert.SerializeObject(content);

            // Act
            ManyResponse <MultipleRelationshipsPrincipalPart> result = _deserializer.DeserializeMany <MultipleRelationshipsPrincipalPart>(body);
            MultipleRelationshipsPrincipalPart resource = result.Data.First();

            // Assert
            Assert.Equal(1, resource.Id);
            MultipleRelationshipsPrincipalPart included = resource.Multi;

            Assert.Equal(10, included.Id);
            Assert.Equal(includedAttributeValue, included.AttributeMember);
            OneToManyDependent nestedIncluded = included.PopulatedToManies.First();

            Assert.Equal(10, nestedIncluded.Id);
            Assert.Equal(nestedIncludedAttributeValue, nestedIncluded.AttributeMember);
            OneToManyPrincipal deeplyNestedIncluded = nestedIncluded.Principal;

            Assert.Equal(10, deeplyNestedIncluded.Id);
            Assert.Equal(deeplyNestedIncludedAttributeValue, deeplyNestedIncluded.AttributeMember);
        }