public void ToJsonTest() { Assert.Equal(string.Empty, SerDeExtensions.ToJson(null)); string str = "Foo Bar"; Assert.Equal(str, SerDeExtensions.ToJson(str)); ITestInterface testObj = new TestClass("Foo") { Prop2 = 100 }; string json = SerDeExtensions.ToJson(testObj); string expectedJson = @"{""Prop1"":""Foo"",""Prop2"":100}"; Assert.Equal(expectedJson, json); ITestInterface jsonConvertedObj = SerDeExtensions.FromJson <TestClass>(json); Assert.NotNull(jsonConvertedObj); Assert.Equal("Foo", jsonConvertedObj.GetProp1()); Assert.Equal(100, jsonConvertedObj.GetProp2()); }
public void StringToJsonRoundtripTest(string input) { string value = SerDeExtensions.FromJson <string>(SerDeExtensions.ToJson(input)); Assert.Equal(input, value); }