public void TestAddToService1ParamCS_ByIdx() { const string testString = "how long is this?"; var exptectedLength = testString.Length; const int testId = 29; const string testMethodName = "testMethod"; var fun = new Func<string, int>(inputString => inputString.Length); // SETUP var rpcHost = new JAAM.RPC.RPCService(); rpcHost.AddToServiceCS(testMethodName, "inputString", fun); // INVOKE var callResult = rpcHost.Invoke(0,new RpcRequest<string>(testMethodName, testString, testId)); Assert.AreEqual(testId, callResult.Id); // make sure we got a result for the same ID we passed in Assert.AreEqual(exptectedLength, callResult.Result); // make sure the result we got matches the calculation Assert.IsNull(callResult.Error); // make sure we didn't error }
public void TestAddToService1ParamCS_ByIdx() { const string testString = "how long is this?"; var exptectedLength = testString.Length; const int testId = 29; const string testMethodName = "testMethod"; var fun = new Func <string, int>(inputString => inputString.Length); // SETUP var rpcHost = new JAAM.RPC.RPCService(); rpcHost.AddToServiceCS(testMethodName, "inputString", fun); // INVOKE var callResult = rpcHost.Invoke(0, new RpcRequest <string>(testMethodName, testString, testId)); Assert.AreEqual(testId, callResult.Id); // make sure we got a result for the same ID we passed in Assert.AreEqual(exptectedLength, callResult.Result); // make sure the result we got matches the calculation Assert.IsNull(callResult.Error); // make sure we didn't error }
public void TestAddToService2ParamCSExpectedFailBecauseParameterTypesDoNotMatchDelegateSignature() { const string testString = "how long is this?"; const int testMul = 23; const int testId = 29; const string testMethodName = "testMethod"; var fun = new Func <string, int, int>((inputString, mul) => inputString.Length * mul); var expectedResult = fun(testString, testMul); // SETUP var rpcHost = new JAAM.RPC.RPCService(); rpcHost.AddToServiceCS(testMethodName, "inputString", "mul", fun); // INVOKE var callResult = rpcHost.Invoke(new RpcRequest <int, string>(testMethodName, testMul, testString, testId)); Assert.IsNotNull(callResult.Error); // make sure we didn't error Assert.AreEqual(testId, callResult.Id); // make sure we got a result for the same ID we passed in Assert.AreNotEqual(expectedResult, callResult.Result); // make sure the result we got matches the calculation }
public void TestAddToService2ParamCSExpectedFailBecauseParameterTypesDoNotMatchDelegateSignature() { const string testString = "how long is this?"; const int testMul = 23; const int testId = 29; const string testMethodName = "testMethod"; var fun = new Func<string, int, int>((inputString, mul) => inputString.Length * mul); var expectedResult = fun(testString, testMul); // SETUP var rpcHost = new JAAM.RPC.RPCService(); rpcHost.AddToServiceCS(testMethodName, "inputString", "mul", fun); // INVOKE var callResult = rpcHost.Invoke(new RpcRequest<int, string>(testMethodName, testMul, testString, testId)); Assert.IsNotNull(callResult.Error); // make sure we didn't error Assert.AreEqual(testId, callResult.Id); // make sure we got a result for the same ID we passed in Assert.AreNotEqual(expectedResult, callResult.Result); // make sure the result we got matches the calculation }