public void SerializeObject()
        {
            var data = new Ewok();

            var result  = _serializer.Serialize(data);
            var payload = JObject.Parse(result);

            Assert.NotNull(payload["data"]);
        }
        public void ResourceHasIdAndType()
        {
            var data = new Ewok();

            var result  = _serializer.Serialize(data);
            var payload = JObject.Parse(result);

            Assert.NotNull(payload["data"]["id"]);
            Assert.Equal("ewok", payload["data"]["type"].Value <string>());
        }
        public void SerializesAttributes()
        {
            var data = new Ewok
            {
                Age  = 1,
                Name = "Wicket"
            };

            var result     = _serializer.Serialize(data);
            var payload    = JObject.Parse(result);
            var attributes = payload["data"]["attributes"];

            Assert.Equal(data.Age, attributes["age"].Value <int>());
            Assert.Equal(data.Name, attributes["name"].Value <string>());
        }
        public void SerializesRelationship()
        {
            var data = new Ewok
            {
                Id      = 0,
                Address = new Address
                {
                    Hut         = 12,
                    TreeVillage = "Endor"
                }
            };

            var result  = _serializer.Serialize(data);
            var payload = JObject.Parse(result);

            Assert.Empty(payload["data"]["relationships"]);
        }
        public void SerializesOneToMany()
        {
            var wicket  = new Ewok();
            var teebo   = new Ewok();
            var village = new Village()
            {
                Ewoks = new List <Ewok> {
                    wicket, teebo
                }
            };

            var result  = _serializer.Serialize(village);
            var payload = JObject.Parse(result);

            var relationships = payload["data"]["relationships"];

            Assert.Equal(2, relationships["ewoks"]["data"].Count());

            var included = payload["included"];

            Assert.NotEmpty(included);
            Assert.Equal(2, included.Count());
        }