Ejemplo n.º 1
0
 public GuidAsRelation(string id = "938")
 {
     Id = id;
     Relation = new GuidAsId();
     Relations = new [] { new GuidAsId(), new GuidAsId() };
 }
Ejemplo n.º 2
0
 public GuidAsRelation(string id = "938")
 {
     Id        = id;
     Relation  = new GuidAsId();
     Relations = new [] { new GuidAsId(), new GuidAsId() };
 }
        public void SerializeOnlyWhatYouHave()
        {
            var company = new GuidAsId();

            var target = new ResourceSerializer(urlBuilder: new DefaultUrlPathBuilder("/api"));

            var resourceResult = new ResourceResult
            {
                Resource = new CompanyResource(),
                Result = company
            };

            var result = JToken.Parse(target.Serialize(resourceResult, GetUri(id: "123").ToString()));
            _output.WriteLine(result.ToString());

            Assert.Null(result["data"]["attributes"]["name"]);
            Assert.Null(result["data"]["attributes"]["location"]);
            Assert.Null(result["data"]["attributes"]["number-of-employees"]);
        }
        public void SupportsGuidIds()
        {
            var guid = new GuidAsId();

            var target = new ResourceSerializer(urlBuilder: new DefaultUrlPathBuilder("/api"));

            var resourceResult = new ResourceResult
            {
                Resource = new PersonWithDefaultIdResource(),
                Result = guid
            };

            var result = JToken.Parse(target.Serialize(resourceResult, GetUri(id: "123").ToString()));
            _output.WriteLine(result.ToString());

            Assert.NotNull(result["data"]["id"]);
            Assert.Equal(guid.Id, Guid.Parse(result["data"]["id"].ToString()));
        }
        public void SerializeOnlyWhatYouHave()
        {
            var company = new GuidAsId();
            var serializer = new ResourceSerializer(company, new CompanyResource(),
                GetUri(id: "123"), DefaultPathBuilder, null);

            var result = serializer.Serialize();
            _output.WriteLine(result.ToString());

            Assert.Null(result["data"]["attributes"]["name"]);
            Assert.Null(result["data"]["attributes"]["location"]);
            Assert.Null(result["data"]["attributes"]["number-of-employees"]);
        }
        public void SupportsGuidIds()
        {
            var guid = new GuidAsId();
            var serializer = new ResourceSerializer(guid, new PersonWithDefaultIdResource(), 
                GetUri(id: "123"), DefaultPathBuilder, null);

            var guidResult = serializer.Serialize();
            _output.WriteLine(guidResult.ToString());

            Assert.NotNull(guidResult["data"]["id"]);
            Assert.Equal(guid.Id, guidResult["data"].Value<Guid>("id"));
        }