public void InstantiateGraphWithModifications() { var resource = new TestNestedResource() { Nested = new TestNestedResource() { Foo = "turtles all the way down?", }, }; resource.GetData().Keys.Should().BeEquivalentTo("nested"); resource.Nested.GetData().Keys.Should().BeEquivalentTo("foo"); }
public void SerializeResource() { var serializer = new DefaultSerializer(); var nestedResource = new TestNestedResource() { Nested = new TestNestedResource() { Nested = new TestNestedResource() { Foo = "foobar", } } }; var json = serializer.Serialize(nestedResource); json.Should().Be("{\"nested\":{\"nested\":{\"foo\":\"foobar\"}}}"); }
public void SerializeResourceWithCustomProperties() { var serializer = new DefaultSerializer(); var customResource = new TestNestedResource() { Foo = "foobar", }; customResource["Custom"] = "Bar"; var foo = new TestNestedResource() { Nested = customResource, }; var json = serializer.Serialize(foo); json.Should().Be("{\"nested\":{\"foo\":\"foobar\",\"Custom\":\"Bar\"}}"); }
public void NotThrowForNonexistentNestedProperty() { var resource = new TestNestedResource(); resource.Nested.Should().NotBeNull(); }