public void When_Null_Object_Should_Then_null_in_String() { FakeNullableData input = null; var jsonService = new JsonService(); var result = jsonService.Serialize(input); var expectedResult = "null"; result.Should().BeEquivalentTo(expectedResult); }
public void When_Object_With_NonNull_Values_Should_Then_Return_Json_WithOut_Those_Values_Contained_In_The_String() { var input = new FakeNullableData { FakeData = "This is some fake input", FakeNullableId = 1 }; var jsonService = new JsonService(); var result = jsonService.Serialize(input); var expectedResult = "{\"FakeNullableId\":1,\"FakeData\":\"This is some fake input\"}"; result.Should().BeEquivalentTo(expectedResult); }
public void When_Json_Does_Not_Contain_Elements_Then_Those_Elements_Should_Be_Null() { var input = "{\"FakeData\":\"This is some fake input\"}"; var jsonService = new JsonService(); var result = jsonService.Deserialize <FakeNullableData>(input); var expectedResult = new FakeNullableData { FakeData = "This is some fake input" }; result.Should().BeEquivalentTo(expectedResult); }