Example #1
0
        public async Task TestServiceManagerAsync()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <IMicroServiceLocator, MicroServiceLocator>();

            services.AddHttpService <IHttpServiceAdapterTestService>("http://{lb:fooservice}/{service}/{action}");

            var provider = services.BuildServiceProvider();

            IHttpServiceAdapterTestService obj = provider.GetService <IHttpServiceAdapterTestService>();

            obj.Click(DateTime.Now);

            await obj.Notify();

            var result = obj.Add(10, 20);

            Assert.AreEqual(30, result);

            var response = obj.Login(new LoginReqeust {
                Mchid = 1, UserName = "******", Password = "******"
            }, "hha");

            Assert.AreEqual(true, response.IsLoginSuccess);

            var num = await obj.NumAddAsync(1, 3);

            Assert.AreEqual(4, num);
        }
Example #2
0
        public async Task TestExecuteServiceAsync()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <IMicroServiceLocator, MicroServiceLocator>();


            HttpServiceAdapter <IHttpServiceAdapterTestService> adapter = new HttpServiceAdapter <IHttpServiceAdapterTestService>("http://{lb:fooservice}/{service}/{action}");


            IHttpServiceAdapterTestService obj = adapter.GetProxyObject(new Castle.DynamicProxy.ProxyGenerator())(services.BuildServiceProvider()) as IHttpServiceAdapterTestService;

            obj.Click(DateTime.Now);

            await obj.Notify();

            //obj.ShowError("haha");
            //await obj.Run();
            //var result = await obj.RunAddAsync( 1, 2 );
            //Assert.AreEqual( 3, result );

            var result = obj.Add(10, 20);

            Assert.AreEqual(30, result);

            var response = obj.Login(new LoginReqeust {
                Mchid = 1, UserName = "******", Password = "******"
            }, "hha");

            Assert.AreEqual(true, response.IsLoginSuccess);

            var num = await obj.NumAddAsync(1, 3);

            Assert.AreEqual(4, num);
        }