public static Tuple <JRpcService, T> StartService <T>(string serviceName, JRpcModule jRpcModule, string ipAdress = null, string port = null) where T : class { if (string.IsNullOrEmpty(ipAdress)) { ipAdress = DEFAULT_IP_ADRESS; } if (string.IsNullOrEmpty(port)) { port = DEFAULT_PORT; } ConfigurationManager.AppSettings.Set("ServiceAddress", ipAdress); ConfigurationManager.AppSettings.Set("ServicePort", port); var consulClient = new ConsulClient(); var registry = new DefaultModulesRegistry(); registry.AddJRpcModule(jRpcModule); var service = new JRpcService(registry, consulClient); service.Start(); var path = $"http://{ipAdress}:{port}"; var client = new JRpcClient(path); var clientProxy = client.GetProxy <T>(serviceName); return(Tuple.Create(service, clientProxy)); }
public void MissValueToNonOptionalParameterForOldClientVersionTest() { var startInfo = ServiceRunner.StartService <ITestServiceWithParametersOldVersion>("TestServiceWithParameters", new TestServiceWithParameters()); _service = startInfo.Item1; _service.Start(); Assert.Throws <JRpcException>(() => startInfo.Item2.MethodWithParameters("smt")); }
public void MissValueToOptionalParameterForOldClientVersionTest() { var startInfo = ServiceRunner.StartService <ITestServiceWithParametersOldVersion>("TestServiceWithParameters", new TestServiceWithParameters()); _service = startInfo.Item1; _service.Start(); Assert.AreEqual(TestServiceWithParameters.DEFAULT_PARAMETER_VALUE, startInfo.Item2.MethodWithDefaulParameter("smt")); }
public void CallMethodWithInterfaceInheritance() { var startInfo = ServiceRunner.StartService <ITestServiceImpl>("TestServiceImpl", new TestServiceImpl()); _service = startInfo.Item1; _service.Start(); Assert.AreEqual(TestService.STRING, startInfo.Item2.GetString()); }
public void CallMethodOnServiceWithMultipleInterfaces() { var startInfo = ServiceRunner.StartService <ITestServiceWithParamsNameMismatch2>("TestServiceWithParamsNameMismatch", new TestServiceWithParamsNameMismatch()); _service = startInfo.Item1; _service.Start(); var paramValue = "test"; Assert.AreEqual(paramValue, startInfo.Item2.AnotherMethod(paramValue)); }
public void CallMethodWithSchemeMismatchTest() { var startInfo = ServiceRunner.StartService <ITestServiceWithParamsNameMismatch>("TestServiceWithParamsNameMismatch", new TestServiceWithParamsNameMismatch()); _service = startInfo.Item1; _service.Start(); var paramValue = "test"; Assert.AreEqual(paramValue, startInfo.Item2.Method(paramValue)); }
public void MissValueToOptionalParameterForClientWithOtherDefaultTest() { var startInfo = ServiceRunner.StartService <ITestServiceWithParametersAndNewDefaultValue>("TestServiceWithParameters", new TestServiceWithParameters()); _service = startInfo.Item1; _service.Start(); var methodWithDefaulParameter = startInfo.Item2.MethodWithDefaulParameter("smt"); Assert.AreEqual(TestServiceWithParameters.NEW_DEFAULT_PARAMETER_VALUE, methodWithDefaulParameter); }
public void PassValueToOptionalParameterTest() { var startInfo = ServiceRunner.StartService <ITestServiceWithParameters>("TestServiceWithParameters", new TestServiceWithParameters()); _service = startInfo.Item1; _service.Start(); var methodWithDefaulParameter = startInfo.Item2.MethodWithDefaulParameter("smt", TestData); Assert.AreEqual(TestData, methodWithDefaulParameter); }
static void Main(string[] args) { var defaultModulesRegistry = new DefaultModulesRegistry(); defaultModulesRegistry.AddJRpcModule(new NewTestService()); var service = new JRpcService(defaultModulesRegistry, new ConsulClient(), new KestrelJRpcServerHost()); service.Start(); Console.WriteLine("Hello World!"); Console.ReadLine(); }
static void Main(string[] args) { var client = new ConsulClient(); var registry = new DefaultModulesRegistry(); registry.AddJRpcModule(new SimpleService()); var svc = new JRpcService(registry, client, new OwinJrpcServer()); svc.Start(); Console.ReadLine(); svc.Stop(); }