public async Task Serialize_ResourceObject_for_resource_with_relationships()
        {
            var mockCapital = new Mock<IRelationshipObject>(MockBehavior.Strict);
            var mockNeighbors = new Mock<IRelationshipObject>(MockBehavior.Strict);

            var mockRelationshipObjectFormatter = new Mock<IRelationshipObjectFormatter>(MockBehavior.Strict);
            mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockCapital.Object, It.IsAny<JsonWriter>()))
                .Returns((IRelationshipObject relationshipObject, JsonWriter writer) =>
                {
                    writer.WriteValue("IRelationship Placeholder - capital");
                    return Task.FromResult(0);
                }).Verifiable();
            mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockNeighbors.Object, It.IsAny<JsonWriter>()))
                .Returns((IRelationshipObject relationshipObject, JsonWriter writer) =>
                {
                    writer.WriteValue("IRelationship Placeholder - neighbors");
                    return Task.FromResult(0);
                }).Verifiable();

            var relationships = new Dictionary<string, IRelationshipObject>
            {
                { "capital", mockCapital.Object },
                { "neighbors", mockNeighbors.Object }
            };
            IResourceObject resourceObject = new ResourceObject("states", "1400", relationships: relationships);

            var formatter = new ResourceObjectFormatter(mockRelationshipObjectFormatter.Object, null, null);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_relationships.json");
            mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockCapital.Object, It.IsAny<JsonWriter>()), Times.Once);
            mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockNeighbors.Object, It.IsAny<JsonWriter>()), Times.Once);
        }
        public async Task Serialize_ResourceObject_for_resource_without_attributes()
        {
            IResourceObject resourceObject = new ResourceObject("countries", "1100");

            var formatter = new ResourceObjectFormatter(null, null, null);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_without_attributes.json");
        }
        public async Task Serialize_ResourceObject_for_resource_with_attributes()
        {
            var attributes = new Dictionary<string, JToken>
            {
                { "name", "Triangle" },
                { "sides", 3 },
                { "foo", null }
            };
            IResourceObject resourceObject = new ResourceObject("shapes", "1400", attributes);

            var formatter = new ResourceObjectFormatter(null, null, null);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_attributes.json");
        }
        public async Task Serialize_ResourceObject_for_resource_with_links()
        {
            var mockLinkFormatter = new Mock<ILinkFormatter>(MockBehavior.Strict);
            mockLinkFormatter.Setup(m => m.Serialize(It.IsAny<ILink>(), It.IsAny<JsonWriter>()))
                .Returns((ILink link, JsonWriter writer) =>
                {
                    writer.WriteValue("ILink placeholder 1");
                    return Task.FromResult(0);
                }).Verifiable();

            var mockSelfLink = new Mock<ILink>(MockBehavior.Strict);

            IResourceObject resourceObject = new ResourceObject("states", "1400", selfLink: mockSelfLink.Object);

            var formatter = new ResourceObjectFormatter(null, mockLinkFormatter.Object, null);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_links.json");
            mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny<JsonWriter>()), Times.Once);
        }
        public async Task Serialize_ResourceObject_for_resource_with_only_null_relationships()
        {
            var relationships = new Dictionary<string, IRelationshipObject>
            {
                { "capital", null }
            };
            IResourceObject resourceObject = new ResourceObject("states", "1400", relationships: relationships);

            var formatter = new ResourceObjectFormatter(null, null, null);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_only_null_relationships.json");
        }
        public async Task Serialize_ResourceObject_for_resource_with_all_possible_members()
        {
            var mockCapital = new Mock<IRelationshipObject>(MockBehavior.Strict);
            var mockNeighbors = new Mock<IRelationshipObject>(MockBehavior.Strict);

            var mockRelationshipObjectFormatter = new Mock<IRelationshipObjectFormatter>(MockBehavior.Strict);
            mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockCapital.Object, It.IsAny<JsonWriter>()))
                .Returns((IRelationshipObject relationshipObject, JsonWriter writer) =>
                {
                    writer.WriteValue("IRelationship Placeholder - capital");
                    return Task.FromResult(0);
                }).Verifiable();
            mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockNeighbors.Object, It.IsAny<JsonWriter>()))
                .Returns((IRelationshipObject relationshipObject, JsonWriter writer) =>
                {
                    writer.WriteValue("IRelationship Placeholder - neighbors");
                    return Task.FromResult(0);
                }).Verifiable();

            var mockLinkFormatter = new Mock<ILinkFormatter>(MockBehavior.Strict);
            mockLinkFormatter.Setup(m => m.Serialize(It.IsAny<ILink>(), It.IsAny<JsonWriter>()))
                .Returns((ILink link, JsonWriter writer) =>
                {
                    writer.WriteValue("ILink placeholder 1");
                    return Task.FromResult(0);
                }).Verifiable();

            var mockMetadataFormatter = new Mock<IMetadataFormatter>(MockBehavior.Strict);
            mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny<IMetadata>(), It.IsAny<JsonWriter>()))
                .Returns((IMetadata metadata, JsonWriter writer) =>
                {
                    writer.WriteValue("IMetadata placeholder 1");
                    return Task.FromResult(0);
                }).Verifiable();


            var attributes = new Dictionary<string, JToken>
            {
                { "name", "New York" },
                { "population", 19746227 },
                { "foo", null }
            };

            var relationships = new Dictionary<string, IRelationshipObject>
            {
                { "capital", mockCapital.Object },
                { "neighbors", mockNeighbors.Object }
            };

            var mockSelfLink = new Mock<ILink>(MockBehavior.Strict);
            var mockMetadata = new Mock<IMetadata>(MockBehavior.Strict);

            IResourceObject resourceObject = new ResourceObject("states", "1400", attributes, relationships, mockSelfLink.Object, mockMetadata.Object);

            var formatter = new ResourceObjectFormatter(mockRelationshipObjectFormatter.Object, mockLinkFormatter.Object, mockMetadataFormatter.Object);
            await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_all_possible_members.json");
            mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockCapital.Object, It.IsAny<JsonWriter>()), Times.Once);
            mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockNeighbors.Object, It.IsAny<JsonWriter>()), Times.Once);
            mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny<JsonWriter>()), Times.Once);
            mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny<JsonWriter>()), Times.Once);
        }