@@ -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 {
0 commit comments