コード例 #1
0
        public async ValueTask <bool> SetParameterAsync(string key, XmlRpcArg value, CancellationToken token = default)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            value.ThrowIfEmpty();
            return((await SetParamAsync(key, value, token)).IsValid);
        }
コード例 #2
0
        public bool SetParameter(string key, XmlRpcArg value)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            value.ThrowIfEmpty();
            return(SetParam(key, value).IsValid);
        }
コード例 #3
0
        public void TestXmlRpcGetUriTimeout()
        {
            var args = new XmlRpcArg[] { CallerId };

            using var source = new CancellationTokenSource();
            source.Cancel();

            Assert.Catch <OperationCanceledException>(() =>
                                                      XmlRpcService.MethodCall(MasterUri, CallerUri, "getUri", args, source.Token));

            Assert.CatchAsync <OperationCanceledException>(async() =>
                                                           await XmlRpcService.MethodCallAsync(MasterUri, CallerUri, "getUri", args, source.Token));
        }
コード例 #4
0
        public async Task TestXmlRpcGetUriAsync()
        {
            var args = new XmlRpcArg[] { CallerId };

            using var source = new CancellationTokenSource();
            source.CancelAfter(3000);

            var response = await XmlRpcService.MethodCallAsync(MasterUri, CallerUri, "getUri", args, source.Token);

            Assert.IsTrue(response.TryGetArray(out var responseArray));
            Assert.IsTrue(responseArray.Length == 3);
            Assert.IsTrue(responseArray[0].TryGetInteger(out int successCode) && successCode == 1);
            Assert.IsTrue(responseArray[1].TryGetString(out _));
            Assert.IsTrue(responseArray[2].TryGetString(out string retMasterUri) &&
                          Uri.TryCreate(retMasterUri, UriKind.Absolute, out _));
        }