Esempio n. 1
0
        public void VerifyTurtleResourceSerialization()
        {
            var turtle = new TurtleResource
            {
                Links    = new TurtleLinks(new SelfLink("/turtle2")),
                Embedded = new EmbeddedTurtle
                {
                    Down = new TurtleResource
                    {
                        Links    = new TurtleLinks(new SelfLink("/turtle1")),
                        Embedded = new EmbeddedTurtle
                        {
                            Down = new TurtleResource {
                                Links = new TurtleLinks(new SelfLink("/turtle0"))
                            }
                        }
                    }
                }
            };

            var json         = Serialize(turtle);
            var expectedJson =
                "{\"_links\":{\"self\":{\"href\":\"/turtle2\"}},\"_embedded\":{\"down\":{\"_links\":{\"self\":{\"href\":\"/turtle1\"}},\"_embedded\":{\"down\":{\"_links\":{\"self\":{\"href\":\"/turtle0\"}}}}}}}";

            json.ShouldBe(expectedJson);
        }
 private static void VerifyTurtles(TurtleResource turtle, params string[] expectedLinks)
 {
     foreach (var pair in turtle.AllTheWayDown().Select(t => t.Links.Self.Href.ToString())
              .Zip(expectedLinks, (actual, expected) => new { actual, expected }))
     {
         pair.actual.ShouldBe(pair.expected);
     }
 }