public void SerializeLinksTest() { var links = new List <Link>() { new Link { Href = "a/b/c", Rel = "first", Method = "Get" }, new Link { Href = "another/link", Rel = "other", Method = "Post" } }; var serializer = new JsonOutputSerializer(new Settings { }); var str = serializer.SerializeLinks(links); var obj = JsonConvert.DeserializeObject <List <Link> >(str); Assert.IsFalse(str.Contains("Href")); Assert.IsTrue(str.Contains("href")); Assert.AreEqual(links.Count, obj.Count); Assert.AreEqual(links[0].Href, obj[0].Href); Assert.AreEqual(links[1].Href, obj[1].Href); }
public void SerializeLinksWithBaseUrlTest2() { var baseUrl = "http://base.url"; var links = new List <Link>() { new Link { Href = "a/b/c", Rel = "first", Method = "Get" }, new Link { Href = "another/link", Rel = "other", Method = "Post" } }; var serializer = new JsonOutputSerializer(new Settings { UseAbsoluteUrl = true, AbsoluteBaseUrl = baseUrl + "/" }); var str = serializer.SerializeLinks(links); var obj = JsonConvert.DeserializeObject <List <Link> >(str); Assert.IsFalse(str.Contains("Href")); Assert.IsTrue(str.Contains("href")); Assert.AreEqual(links.Count, obj.Count); Assert.AreEqual(baseUrl + "/" + links[0].Href, obj[0].Href); Assert.AreEqual(baseUrl + "/" + links[1].Href, obj[1].Href); }