public void SirenEntity_DeserializesCorrectly() { ISirenEntity sirenEntity = new SirenEntity( properties: new { foo = "bar", baz = new { baz1 = "cats", baz2 = 2, baz3 = true } }, links: new[] { new SirenLink(rel: new[] { "self" }, href: new Uri("http://example.com"), @class: new[] { "class" }) }, rel: new[] { "organization" }, @class: new[] { "some-class" }, entities: new[] { new SirenEntity() }, actions: new[] { new SirenAction(name: "action-name", href: new Uri("http://example.com"), @class: new[] { "class" }) }, title: "Entity title", href: new Uri("http://example.com/3"), type: "text/html" ); string serialized = JsonConvert.SerializeObject(sirenEntity); ISirenEntity entity = JsonConvert.DeserializeObject <SirenEntity>(serialized); Assert.AreEqual("bar", (string)entity.Properties.foo); Assert.AreEqual("cats", (string)entity.Properties.baz.baz1); Assert.AreEqual(2, (int)entity.Properties.baz.baz2); Assert.AreEqual(true, (bool)entity.Properties.baz.baz3); Assert.AreEqual(1, entity.Links.ToList().Count); Assert.Contains("organization", entity.Rel); Assert.Contains("some-class", entity.Class); Assert.AreEqual(1, entity.Entities.ToList().Count); Assert.AreEqual(1, entity.Actions.ToList().Count); Assert.AreEqual("Entity title", entity.Title); Assert.AreEqual("http://example.com/3", entity.Href.ToString()); Assert.AreEqual("text/html", entity.Type); Assert.AreNotEqual(0, entity.GetHashCode()); }
public void SirenEntity_GetHashCode_NotEqual(ISirenEntity entity1, ISirenEntity entity2) { Assert.AreNotEqual(entity1.GetHashCode(), entity2.GetHashCode()); }
public void SirenEntity_GetHashcodeNot0(ISirenEntity entity) { Assert.AreNotEqual(0, entity.GetHashCode()); }