public void TestRequestPathFind() { var deferred = new Task(() => { }); _remote = new Remote(ServerUrl); MessageResult <PathFindResponse> response = null; _remote.Connect(r => { var options = new PathFindOptions(); options.Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1"; options.Destination = "jBKaXuYemkAb5HytZgosAcWgWDZbBvz6KR"; options.Amount = new Amount("CNY", "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS", "0.1"); var req = _remote.RequestPathFind(options); req.Submit(r1 => { response = r1; deferred.Start(); }); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var result = response.Result; Assert.IsNotNull(result); Assert.AreEqual("j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1", result.Source); Assert.AreEqual("jBKaXuYemkAb5HytZgosAcWgWDZbBvz6KR", result.Destination); }
private void InitRequestPathFindOptions() { var options = new PathFindOptions(); options.Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1"; options.Destination = "jBKaXuYemkAb5HytZgosAcWgWDZbBvz6KR"; options.Amount = new Amount { Currency = "CNY", Issuer = "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS", Value = "0.01" }; pgRequestPathFindOptions.SelectedObject = options; }
public void TestRequestPathFindResponse() { var remote = new Remote(""); remote.SetMockServer(new MockServer(remote, "RequestPathFind.json")); MessageResult <PathFindResponse> response = null; var deferred = new Task(() => { }); var options = new PathFindOptions(); options.Account = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr"; options.Destination = "jaVDaozkmFzCGwuBYL5wQ3SvhnUrySuofn"; options.Amount = new Amount { Currency = "CNY", Issuer = "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or", Value = "0.01" }; remote.RequestPathFind(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var result = response.Result; Assert.IsNotNull(result); Assert.AreEqual("jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", result.Source); Assert.AreEqual("jaVDaozkmFzCGwuBYL5wQ3SvhnUrySuofn", result.Destination); Assert.AreEqual(new Amount { Currency = "CNY", Issuer = "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or", Value = "0.001" }, result.Amount); Assert.AreEqual(1, result.Alternatives.Length); var path0 = result.Alternatives[0]; Assert.IsNotNull(path0.Key); Assert.AreEqual(new Amount { Currency = "SWT", Issuer = "", Value = "0.024661" }, path0.Choice); }
public void TestRequestPathFind_Invalid() { var deferred = new Task(() => { }); MessageResult <PathFindResponse> response = null; var options = new PathFindOptions(); options.Account = "abcxyz"; options.Destination = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr"; options.Amount = new Amount { Currency = "ABC", Issuer = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", Value = "1" }; _remote.RequestPathFind(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidAddressException)); var ex = response.Exception as InvalidAddressException; Assert.AreEqual("Account", ex.Name); deferred = new Task(() => { }); response = null; options = new PathFindOptions(); options.Account = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr"; options.Destination = "abcxyz"; options.Amount = new Amount { Currency = "ABC", Issuer = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", Value = "1" }; _remote.RequestPathFind(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidAddressException)); ex = response.Exception as InvalidAddressException; Assert.AreEqual("Destination", ex.Name); deferred = new Task(() => { }); response = null; options = new PathFindOptions(); options.Account = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr"; options.Destination = "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr"; options.Amount = new Amount { Currency = "ABC", Issuer = "abcxyz", Value = "1" }; _remote.RequestPathFind(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidAmountException)); var ex1 = response.Exception as InvalidAmountException; Assert.AreEqual("Amount", ex1.Name); }