コード例 #1
0
        public void ToObject_ReturnsCorrectObject()
        {
            var jObject = JObject.FromObject(_expectedObject);
            var a       = JsonSerializationUtilities.ToObject <A>(jObject);

            Assert.Equal(3, a.B);
        }
コード例 #2
0
ファイル: TestablePlugin.cs プロジェクト: dslzuha/nugetclient
        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);
        }
コード例 #3
0
        public void ToObject_ThrowsForNullValue()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => JsonSerializationUtilities.ToObject <A>(jObject: null));

            Assert.Equal("jObject", exception.ParamName);
        }