Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b9f3d7

Browse filesBrowse files
committed
Got Rommar's tests in. Not sure how they got lost in the merge.
1 parent f92ee3d commit 6b9f3d7
Copy full SHA for 6b9f3d7

2 files changed

+39Lines changed: 39 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎AustinHarris.JsonRpcTestN/Test.cs‎

Copy file name to clipboardExpand all lines: AustinHarris.JsonRpcTestN/Test.cs
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,32 @@ public void TestExtraParameters()
18551855
Assert.IsTrue(result.Result.Contains("\"code\":-32602"));
18561856
}
18571857

1858+
[Test()]
1859+
public void TestCustomParameterName()
1860+
{
1861+
Func<string, string> request = (string paramName) => String.Format("{{method:'TestCustomParameterName',params:{{ {0}:'some string'}},id:1}}", paramName);
1862+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
1863+
// Check custom param name specified in attribute works
1864+
var result = JsonRpcProcessor.Process(request("myCustomParameter"));
1865+
result.Wait();
1866+
Assert.AreEqual(JObject.Parse(expectedResult), JObject.Parse(result.Result));
1867+
// Check method can't be used with its actual parameter name
1868+
result = JsonRpcProcessor.Process(request("arg"));
1869+
result.Wait();
1870+
StringAssert.Contains("-32602", result.Result); // check for 'invalid params' error code
1871+
}
1872+
1873+
[Test()]
1874+
public void TestCustomParameterWithNoSpecificName()
1875+
{
1876+
Func<string, string> request = (string paramName) => String.Format("{{method:'TestCustomParameterWithNoSpecificName',params:{{ {0}:'some string'}},id:1}}", paramName);
1877+
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
1878+
// Check method can be used with its parameter name
1879+
var result = JsonRpcProcessor.Process(request("arg"));
1880+
result.Wait();
1881+
Assert.AreEqual(JObject.Parse(expectedResult), JObject.Parse(result.Result));
1882+
}
1883+
18581884
[Test]
18591885
public void TestNestedReturnType()
18601886
{
Collapse file

‎AustinHarris.JsonRpcTestN/service.cs‎

Copy file name to clipboardExpand all lines: AustinHarris.JsonRpcTestN/service.cs
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ private string devideByZero(string s)
7979
return s + j / i;
8080
}
8181

82+
83+
[JsonRpcMethod]
84+
private bool TestCustomParameterName([JsonRpcParam("myCustomParameter")] string arg)
85+
{
86+
return true;
87+
}
88+
89+
[JsonRpcMethod]
90+
private bool TestCustomParameterWithNoSpecificName([JsonRpcParam] string arg)
91+
{
92+
return true;
93+
}
94+
8295
[JsonRpcMethod]
8396
private string StringToRefException(string s, ref JsonRpcException refException)
8497
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.