public void HandlesRecursiveProperties() { var firstModel = new Recursion.FirstModel(); var secondModel = new Recursion.SecondModel(); firstModel.Model = secondModel; secondModel.Model = firstModel; var target = new ResourceSerializer(firstModel, new Recursion.Resource(), GetUri(id: "123"), DefaultPathBuilder, null); var result = target.Serialize(); _output.WriteLine(result.ToString()); var id = result["data"].Value<string>("id"); Assert.Equal(firstModel.Id, id); }
public void HandlesRecursiveProperties() { var firstModel = new Recursion.FirstModel(); var secondModel = new Recursion.SecondModel(); firstModel.Model = secondModel; secondModel.Model = firstModel; var target = new ResourceSerializer(urlBuilder: new DefaultUrlPathBuilder("/api")); var resourceResult = new ResourceResult { Resource = new Recursion.Resource(), Result = firstModel }; var result = JToken.Parse(target.Serialize(resourceResult, GetUri(id: "123").ToString())); _output.WriteLine(result.ToString()); var id = result["data"].Value<string>("id"); Assert.Equal(firstModel.Id, id); }