public void ToObject_ReturnsCorrectObject() { var jObject = JObject.FromObject(_expectedObject); var a = JsonSerializationUtilities.ToObject <A>(jObject); Assert.Equal(3, a.B); }
public async Task HandleResponseAsync( IConnection connection, Message message, IResponseHandler responseHandler, CancellationToken cancellationToken) { var response = _responses.Take(); if (message.Type == MessageType.Request) { switch (message.Method) { case MessageMethod.Initialize: { var initializeRequest = JsonSerializationUtilities.ToObject <InitializeRequest>(message.Payload); _plugin.Connection.Options.SetRequestTimeout(initializeRequest.RequestTimeout); } break; case MessageMethod.Close: _cancellationTokenSource.Cancel(); break; default: break; } } await responseHandler.SendResponseAsync(message, response.Payload, cancellationToken); }
public void ToObject_ThrowsForNullValue() { var exception = Assert.Throws <ArgumentNullException>( () => JsonSerializationUtilities.ToObject <A>(jObject: null)); Assert.Equal("jObject", exception.ParamName); }