public void TopLevelPropertiesCanBeSerializedError() { IJsonRpcMessageFactory factory = this.formatter; var message = factory.CreateErrorMessage(); Assert.NotNull(message); message.Error = new JsonRpcError.ErrorDetail() { Message = "test" }; Assert.True(message.TrySetTopLevelProperty("testProperty", "testValue")); Assert.True(message.TrySetTopLevelProperty("objectProperty", new CustomType() { Age = 25 })); var roundTripMessage = this.Roundtrip(message); Assert.True(roundTripMessage.TryGetTopLevelProperty("testProperty", out string?value)); Assert.Equal("testValue", value); Assert.True(roundTripMessage.TryGetTopLevelProperty("objectProperty", out CustomType? customObject)); Assert.Equal(25, customObject?.Age); }
public void TopLevelPropertiesWithNullValue() { IJsonRpcMessageFactory factory = this.formatter; var requestMessage = factory.CreateRequestMessage(); Assert.NotNull(requestMessage); requestMessage.Method = "test"; Assert.True(requestMessage.TrySetTopLevelProperty <string?>("testProperty", null)); var roundTripMessage = this.Roundtrip(requestMessage); Assert.True(roundTripMessage.TryGetTopLevelProperty("testProperty", out string?value)); Assert.Null(value); }
public void TopLevelPropertiesCanBeSerializedRequest() { IJsonRpcMessageFactory factory = this.formatter; var requestMessage = factory.CreateRequestMessage(); Assert.NotNull(requestMessage); requestMessage.Method = "test"; Assert.True(requestMessage.TrySetTopLevelProperty("testProperty", "testValue")); Assert.True(requestMessage.TrySetTopLevelProperty("objectProperty", new CustomType() { Age = 25 })); var roundTripMessage = this.Roundtrip(requestMessage); Assert.True(roundTripMessage.TryGetTopLevelProperty("testProperty", out string?value)); Assert.Equal("testValue", value); Assert.True(roundTripMessage.TryGetTopLevelProperty("objectProperty", out CustomType? customObject)); Assert.Equal(25, customObject?.Age); }