>(sstream);
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- Debugger.Break();
- }
-
- if (rjson == null)
- {
- if (!string.IsNullOrEmpty(sstream))
- {
- JObject jo = Newtonsoft.Json.JsonConvert.DeserializeObject(sstream) as JObject;
- obs.OnError(new Exception(jo["Error"].ToString()));
- }
- else
- {
- obs.OnError(new Exception("Empty response"));
- }
- }
-
- obs.OnNext(rjson);
- obs.OnCompleted();
- }), request);
- }), req);
- }));
-
- return res;
- }
-
- }
-}
diff --git a/AustinHarris.JsonRpc.Client/packages.config b/AustinHarris.JsonRpc.Client/packages.config
deleted file mode 100644
index 17e45de..0000000
--- a/AustinHarris.JsonRpc.Client/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17a2936..1f4b2e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,7 @@ behaviour: a breaking change to either means a new major version.
- The `JsonSerializerSettings` overloads of `JsonRpcProcessor.Process*` (pass a serializer instead; the Newtonsoft package has settings-based helpers).
- Json.NET attributes on `JsonRequest`, `JsonResponse` and `JsonRpcException`.
+- The 1.x projects that 2.0 did not build: `AustinHarris.JsonRpc.Client`, `AustinHarris.JsonRpc.AspNet`, the Windows Phone 7 client, `JsonRpcTest` and `TestClient`. They were .NET Framework 4.0 `packages.config` projects outside the solution, referencing packages with open advisories; their source is in the git history before 2.0.
### Fixed
diff --git a/JsonRpcTest/Global.asax b/JsonRpcTest/Global.asax
deleted file mode 100644
index 7632cd0..0000000
--- a/JsonRpcTest/Global.asax
+++ /dev/null
@@ -1 +0,0 @@
-<%@ Application Codebehind="Global.asax.cs" Inherits="JsonRpcTest.Global" Language="C#" %>
diff --git a/JsonRpcTest/Global.asax.cs b/JsonRpcTest/Global.asax.cs
deleted file mode 100644
index 92fb31b..0000000
--- a/JsonRpcTest/Global.asax.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using AustinHarris.JsonRpc;
-using System;
-
-namespace JsonRpcTest{
- public class Global : System.Web.HttpApplication {
- static object[] services = new object[] {
- new TestServer.HelloWorldService(),
- new TestServer.TestService(),
-
- };
- protected void Application_Start(object sender, EventArgs e) {
- AustinHarris.JsonRpc.Config.SetErrorHandler(OnJsonRpcException);
- Config.SetPreProcessHandler(new PreProcessHandler(PreProcess));
- }
-
- private AustinHarris.JsonRpc.JsonRpcException OnJsonRpcException(AustinHarris.JsonRpc.JsonRequest rpc, AustinHarris.JsonRpc.JsonRpcException ex)
- {
- return ex;
- }
-
- private JsonRpcException PreProcess(JsonRequest rpc, object context)
- {
- // Useful for logging or authentication using the context.
-
- if(!string.Equals(rpc.Method, "RequiresCredentials",StringComparison.CurrentCultureIgnoreCase))
- return null;
-
- // If this is using the ASP.Net handler then the context will contain the httpRequest
- // you could use that for cookies or IP authentication.
-
- // Here we will just check that the first parameter is a magic Key
- // DO NOT do this type of thing in production code. You would be better just checking the parameter inside the JsonRpcMethod.
- var j = rpc.Params as Newtonsoft.Json.Linq.JArray;
- if (j == null
- || j[0] == null
- || j[0].Type != Newtonsoft.Json.Linq.JTokenType.String
- || !string.Equals(j[0].ToString(), "GoodPassword", StringComparison.CurrentCultureIgnoreCase)
- ) return new JsonRpcException(-2, "This exception was thrown using: JsonRpcTest.Global.PreProcess, Not Authenticated", null);
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/JsonRpcTest/HelloWorldService.cs b/JsonRpcTest/HelloWorldService.cs
deleted file mode 100644
index e5a7547..0000000
--- a/JsonRpcTest/HelloWorldService.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace TestServer{
- using System;
- using AustinHarris.JsonRpc;
-
- public class HelloWorldService: JsonRpcService{
- [JsonRpcMethod]
- private string helloWorld(string message){
- return "Hello World "+ message;
- }
- }
-}
\ No newline at end of file
diff --git a/JsonRpcTest/HttpGetExamples.html b/JsonRpcTest/HttpGetExamples.html
deleted file mode 100644
index 4372a77..0000000
--- a/JsonRpcTest/HttpGetExamples.html
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
- The methods being invoked can be found in TestService.cs
- These examples use HTTP GET to make the JsonRpc request. I recommend Fiddler2 to peek at http traffic.
- An example of a get request looks like:
-
- /json.rpc?jsonrpc={'method':'internal.echo','params':['Echo%20This'],'id':2}
-
-
-
-
diff --git a/JsonRpcTest/Properties/AssemblyInfo.cs b/JsonRpcTest/Properties/AssemblyInfo.cs
deleted file mode 100644
index 3b8f770..0000000
--- a/JsonRpcTest/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("JsonRpcTest")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("JsonRpcTest")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("0f411817-d0c2-4bd8-b835-e8eb54d37a5f")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/JsonRpcTest/TestServer.csproj b/JsonRpcTest/TestServer.csproj
deleted file mode 100644
index c4aff2e..0000000
--- a/JsonRpcTest/TestServer.csproj
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
-
-
- 2.0
- {A1077F2C-62A2-4EF6-BDF3-FB6F539A90A9}
- {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
- Library
- Properties
- JsonRpcTest
- JsonRpcTest
- v4.0
- false
- SAK
- SAK
- SAK
- SAK
-
-
-
-
- 4.0
-
-
-
-
-
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- AnyCPU
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
-
-
-
-
- False
- ..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Designer
-
-
- Web.config
-
-
- Web.config
-
-
-
-
-
- Global.asax
-
-
-
-
-
-
- {fffdebbc-93f5-4a22-9ec5-d86a4a792dbb}
- AustinHarris.JsonRpc.AspNet
-
-
- {24FC1A2A-0BC3-43A7-9BFE-B628C2C4A307}
- AustinHarris.JsonRpc
-
-
-
-
-
-
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
-
-
-
-
-
-
- False
- False
- 49718
- /
- http://localhost/TestSever
- False
- False
-
-
- False
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JsonRpcTest/TestService.cs b/JsonRpcTest/TestService.cs
deleted file mode 100644
index e6947b7..0000000
--- a/JsonRpcTest/TestService.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-namespace TestServer
-{
- using System;
- using System.Collections.Generic;
- using AustinHarris.JsonRpc;
- using Newtonsoft.Json.Linq;
-
- public class TestService: JsonRpcService
- {
- [JsonRpcMethod("internal.echo")]
- private string Handle_Echo(string s)
- {
- return s;
- }
-
-
- [JsonRpcMethod]
- private string myIp()
- {
- var req = JsonRpcContext.Current().Value as System.Web.HttpRequest;
- if (req != null)
- return req.UserHostAddress;
- return "IP not available";
- }
-
- [JsonRpcMethod]
- private string myUserAgent()
- {
- var req = JsonRpcContext.Current().Value as System.Web.HttpRequest;
- if (req != null)
- return req.UserAgent.ToString();
- return "hmm. no UserAgent";
- }
-
- [JsonRpcMethod("error1")]
- private string devideByZero(string s)
- {
- var i = 0;
- var j = 15;
- return s + j / i; // This causes the framework to throw an exception
- }
-
- [JsonRpcMethod("error2")]
- private string throwsException(string s, ref JsonRpcException refException)
- {
- refException = new JsonRpcException(-1, "This exception was thrown using: ref JsonRpcException", null);
- return s;
- }
-
- [JsonRpcMethod("error3")]
- private string throwsException2(string s)
- {
- throw new JsonRpcException(-27000, "This exception was thrown using: throw new JsonRpcException()", null);
- return s;
- }
-
- [JsonRpcMethod("error4")]
- private string throwsException3(string s)
- {
- JsonRpcContext.SetException(new JsonRpcException(-27000, "This exception was thrown using: JsonRpcContext.Current().SetException()", null));
- return s;
- }
-
- [JsonRpcMethod]
- private string RequiresCredentials(string magicKey)
- {
- return "Passed Authentication";
- }
-
- [JsonRpcMethod]
- private DateTime testDateTime()
- {
- return DateTime.Now;
- }
-
- [JsonRpcMethod]
- private recursiveClass testRecursiveClass()
- {
- var obj = new recursiveClass() { Value1 = 10, Nested1 = new recursiveClass() { Value1 = 5 } };
- //obj.Nested1.Nested1 = obj;
- return obj;
- }
-
- [JsonRpcMethod]
- private JObject testArbitraryJObject(JObject input)
- {
- return input;
- }
-
- [JsonRpcMethod]
- private List testFloat(float input)
- {
- return new List() { "one", "two", "three", input.ToString() };
- }
-
- [JsonRpcMethod]
- private List testInt(int input)
- {
- return new List() { "one", "two", "three", input.ToString() };
- }
-
- [JsonRpcMethod]
- private object[] testMultipleParameters(string one, int two, float three, CustomString four)
- {
- return new object[] { one, two, three, four };
- }
-
- [JsonRpcMethod("testSimpleString")]
- private List testSimpleString(string input)
- {
- return new List() { "one", "two", "three", input };
- }
-
- [JsonRpcMethod]
- private List testThrowingException(string input)
- {
- throw new Exception("Throwing Exception");
- return new List() { "one", "two", "three", input };
- }
-
- public class CustomString
- {
- public string str;
- }
-
- [JsonRpcMethod("testCustomString")]
- private List testCustomString(CustomString input)
- {
- return new List() { "one", "two", "three", input.str };
- }
-
- private class recursiveClass
- {
- public recursiveClass Nested1 { get; set; }
- public int Value1 { get; set; }
- }
- }
-}
\ No newline at end of file
diff --git a/JsonRpcTest/Web.Debug.config b/JsonRpcTest/Web.Debug.config
deleted file mode 100644
index 2c6dd51..0000000
--- a/JsonRpcTest/Web.Debug.config
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JsonRpcTest/Web.Release.config b/JsonRpcTest/Web.Release.config
deleted file mode 100644
index 4122d79..0000000
--- a/JsonRpcTest/Web.Release.config
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JsonRpcTest/Web.config b/JsonRpcTest/Web.config
deleted file mode 100644
index a577eb8..0000000
--- a/JsonRpcTest/Web.config
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JsonRpcTest/packages.config b/JsonRpcTest/packages.config
deleted file mode 100644
index 12fef57..0000000
--- a/JsonRpcTest/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 75d9f02..c1742e8 100644
--- a/README.md
+++ b/README.md
@@ -705,7 +705,7 @@ dotnet test AustinHarris.JsonRpcTestN
The test suite runs its protocol cases once per serializer (built-in, Json.NET, System.Text.Json) plus the parser, dispatch, version-policy and Kestrel integration tests, on both `net8.0` and `net10.0`. Building a package project in Release produces its NuGet package in `bin/Release/`. The WebAssembly sample builds without the `wasm-tools` workload; add it for AOT.
-`AustinHarris.JsonRpc.Client`, `AustinHarris.JsonRpc.AspNet`, `JsonRpcTest` and `TestClient` are 1.x projects that are still in the tree but outside the solution; nothing in 2.0 is built from them.
+The 1.x projects that 2.0 does not build (`AustinHarris.JsonRpc.Client`, `AustinHarris.JsonRpc.AspNet`, the Windows Phone 7 client, `JsonRpcTest` and `TestClient`) are no longer in the tree. Their source is in the git history before 2.0, and the 1.x packages stay on NuGet.
### Charts
diff --git a/TestClient/Properties/AssemblyInfo.cs b/TestClient/Properties/AssemblyInfo.cs
deleted file mode 100644
index eea0cef..0000000
--- a/TestClient/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("TestClient")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("TestClient")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("354ab9d1-3f99-4e35-a007-6dfeeac07cb1")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TestClient/TestClient.csproj b/TestClient/TestClient.csproj
deleted file mode 100644
index 93f7ddb..0000000
--- a/TestClient/TestClient.csproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
- Debug
- AnyCPU
-
-
- 2.0
- {FA27C906-3591-48A5-B180-646EA6521E3E}
- Library
- Properties
- TestClient
- TestClient
- v4.0
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- SAK
- SAK
- SAK
- SAK
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
- False
- ..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll
-
-
-
- 3.5
-
-
- ..\packages\Rx-Main.1.0.10621\lib\Net4\System.Reactive.dll
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
-
-
- {03FF12D9-6027-4050-81AC-A90B0EA8F8EB}
- AustinHarris.JsonRpc.Client
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TestClient/UnitTest1.cs b/TestClient/UnitTest1.cs
deleted file mode 100644
index fa0193a..0000000
--- a/TestClient/UnitTest1.cs
+++ /dev/null
@@ -1,715 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Reactive.Concurrency;
-using System.Reactive.Linq;
-using System.Threading;
-using AustinHarris.JsonRpc;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Newtonsoft.Json.Linq;
-using System.Text.RegularExpressions;
-
-namespace TestClient
-{
- //[TestClass]
- public class UnitTest1
- {
- Random r = null;
- Uri remoteUri = new Uri("http://localhost.:49718/json.rpc");
- public UnitTest1()
- {
- r = new Random(Environment.TickCount);
- }
-
- [TestMethod]
- public void TestHelloWorld()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
- var myObs = client.Invoke("helloWorld", "My Message", Scheduler.TaskPool);
-
- using (myObs.Subscribe(
- onNext: _ =>
- {
- Console.WriteLine(_.Result);
- Assert.IsTrue(_.Result == "Hello World My Message");
- },
- onError: _ =>
- {
- Assert.Fail();
- are.Set();
- },
- onCompleted: () => are.Set()
- ))
- {
- are.WaitOne();
- }
- }
-
- private string getPrintableString(int len)
- {
- return new string(Enumerable.Range(0, r.Next(len)).Select(_ => (char)r.Next(32, 126)).ToArray());
- }
-
- private string getNonPrintableString(int len)
- {
- return new string(Enumerable.Range(0, r.Next(len)).Select(_ => (char)r.Next(0, 31)).ToArray());
- }
-
- private string getExtendedAsciiString(int len)
- {
- return new string(Enumerable.Range(0, r.Next(len)).Select(_ => (char)r.Next(0, 255)).ToArray());
- }
-
- [TestMethod]
- public void TestArbitrary()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
- var arbitrary = new Newtonsoft.Json.Linq.JObject();
- JObject r = null;
- Exception e = null;
- for (int i = 0; i < 10; i++)
- {
- arbitrary[getPrintableString(10)] = getPrintableString(20);
- arbitrary[getNonPrintableString(10)] = getNonPrintableString(20);
- arbitrary[getExtendedAsciiString(10)] = getExtendedAsciiString(20);
- }
-
- var myObs = client.Invoke("testArbitraryJObject", arbitrary, Scheduler.TaskPool);
-
- using(myObs.Subscribe(
- onNext: (jo) =>
- {
- r = jo.Result;
- },
- onError: _ =>
- {
- e = _;
- },
- onCompleted: () => are.Set()
- ))
- {
- are.WaitOne();
- };
-
-
- Assert.IsTrue(r.ToString() == arbitrary.ToString());
- Assert.IsTrue(e == null);
- }
-
- private JObject CreateArbitraryJObject()
- {
- var arbitrary = new Newtonsoft.Json.Linq.JObject();
- for (int i = 0; i < 1; i++)
- {
- arbitrary[getPrintableString(4)] = getPrintableString(4);
- arbitrary[getNonPrintableString(4)] = getNonPrintableString(4);
- arbitrary[getExtendedAsciiString(4)] = getExtendedAsciiString(4);
- }
- return arbitrary;
- }
-
- [TestMethod]
- public void TestRpcPerSecond()
- {
- // This test sometimes fails due to overloading
- // the network buffer
- var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
- var abjo = CreateArbitraryJObject();
- var limit = 50;
- var passes = 5;
- var requestStream = Observable.Generate(0,
- i => i < limit,
- i => i+1,
- i => abjo
- );
- for (int i = 0; i < passes; i++)
- {
- var tmr = Stopwatch.StartNew();
- SendRequestsAndWait(client, requestStream);
- tmr.Stop();
- var perSecond = (decimal)limit * (1000 / (decimal)tmr.ElapsedMilliseconds);
- Console.WriteLine("Pass{0} - {1} requests in : {2}ms for {3} requests per second", i, limit, tmr.ElapsedMilliseconds, (int)perSecond);
- limit = limit * 2;
- Thread.Sleep(200);
- }
- }
-
- [TestMethod]
- public void TestNetworkBuffer()
- {
- // This will overflow the network buffer.
-
- //var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
- //var abjo = CreateArbitraryJObject();
- //var limit = 10000;
- //var passes = 2;
- //var requestStream = Observable.Generate(0,
- // i => i < limit,
- // i => i + 1,
- // i => abjo
- // );
- //for (int i = 0; i < passes; i++)
- //{
- // var tmr = Stopwatch.StartNew();
- // SendRequestsAndWait(client, requestStream);
- // tmr.Stop();
- // var perSecond = (decimal)limit * (1000 / (decimal)tmr.ElapsedMilliseconds);
- // Console.WriteLine("Pass{0} - {1} requests in : {2}ms for {3} requests per second", i, limit, tmr.ElapsedMilliseconds, (int)perSecond);
- // limit = limit * 2;
- //}
- }
-
- private void SendRequestsAndWait(JsonRpcClient client, IObservable requestStream)
- {
- // chaining is fun
- var mre = new ManualResetEventSlim(false);
- using ((from request in requestStream
- select client.Invoke("testArbitraryJObject", request, Scheduler.TaskPool))
- .Merge()
- .Subscribe(
- onNext: _ => { /* do nothing and like it */ },
- onError: _ => {Debug.WriteLine(_.Message); mre.Set();},
- onCompleted: mre.Set))
- {
- mre.Wait();
- }
- }
-
- [TestMethod]
- public void TestMetaData()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "?";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, null, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
-
- }
-
- [TestMethod]
- public void TestEcho()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "internal.echo";
- string input = "Echo this sucka";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input , Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
- Assert.IsTrue(res == input.ToString());
- }
-
- [TestMethod]
- public void TestFloat()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testFloat";
- float input = 7.1f;
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input , Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
- Assert.IsTrue(res is IList);
- var il = res as IList;
- Assert.IsTrue(il[0] == "one");
- Assert.IsTrue(il[1] == "two");
- Assert.IsTrue(il[2] == "three");
- Assert.IsTrue(il[3] == input.ToString());
- Assert.IsTrue(il.Count == 4);
- }
-
- [TestMethod]
- public void TestInt()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testInt";
- int input = 7;
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input , Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
- Assert.IsTrue(res is IList);
- var il = res as IList;
- Assert.IsTrue(il[0] == "one");
- Assert.IsTrue(il[1] == "two");
- Assert.IsTrue(il[2] == "three");
- Assert.IsTrue(il[3] == input.ToString());
- Assert.IsTrue(il.Count == 4);
- }
-
- [TestMethod]
- public void TestSimpleString()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testSimpleString";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
- Assert.IsTrue(res is IList);
- var il = res as IList;
- Assert.IsTrue(il[0] == "one");
- Assert.IsTrue(il[1] == "two");
- Assert.IsTrue(il[2] == "three");
- Assert.IsTrue(il[3] == input.ToString());
- Assert.IsTrue(il.Count == 4);
- }
-
- [TestMethod]
- public void TestThrowingException()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testThrowingException";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "Internal Error");
- }
- }
-
- [TestMethod]
- public void TestException()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "error1";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "Internal Error");
- }
- }
-
- [TestMethod]
- public void TestrefException()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "error2";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "This exception was thrown using: ref JsonRpcException");
- }
- }
-
- [TestMethod]
- public void TestThrowingJsonRpcException()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "error3";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "This exception was thrown using: throw new JsonRpcException()");
- }
- }
-
- [TestMethod]
- public void TestSettingJsonRpcExceptionWithContext()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "error4";
- string input = "Hello";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "This exception was thrown using: JsonRpcContext.Current().SetException()");
- }
- }
-
- [TestMethod]
- public void TestPreProcessingException()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "RequiresCredentials";
- string input = "BadPassword";
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- Assert.IsTrue(result.Result == null);
- var res = result.Error;
- Assert.IsTrue(res is AustinHarris.JsonRpc.JsonRpcException);
- if (res is JsonRpcException)
- {
- Assert.IsTrue(res.message == "This exception was thrown using: JsonRpcTest.Global.PreProcess, Not Authenticated");
- }
- }
-
- [TestMethod]
- public void TestCustomString()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testCustomString";
- var input = new { str = "Hello" };
- JsonResponse result = null;
- var myObs = rpc.Invoke(method, input, Scheduler.TaskPool);
-
- myObs.Subscribe(
- onNext: _ =>
- {
- result = _;
- are.Set();
- },
- onError: _ =>
- {
- are.Set();
- },
- onCompleted: () => { are.Set(); }
- );
-
- are.WaitOne();
-
- Assert.IsTrue(result != null);
- var res = result.Result;
- Assert.IsTrue(res is IList);
- var il = res as IList;
- Assert.IsTrue(il[0] == "one");
- Assert.IsTrue(il[1] == "two");
- Assert.IsTrue(il[2] == "three");
- Assert.IsTrue(il[3] == input.str);
- Assert.IsTrue(il.Count == 4);
- }
-
- [TestMethod]
- public void TestMultipleParameters()
- {
- AutoResetEvent are = new AutoResetEvent(false);
- var rpc = new JsonRpcClient(remoteUri);
- string method = "testMultipleParameters";
- var anon = new CustomString { str = "Hello" };
- var input = new object[] {"one", 2, 3.3f, anon};
- JsonResponse