Beispiel #1
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));
        }
Beispiel #2
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 _));
        }