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); }
public bool SetParameter(string key, XmlRpcArg value) { if (key == null) { throw new ArgumentNullException(nameof(key)); } value.ThrowIfEmpty(); return(SetParam(key, value).IsValid); }
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)); }
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 _)); }