public async Task TestExecuteServiceAsync() { LocalServiceAdapter <ILocalServiceAdapterTestService> adapter = new LocalServiceAdapter <ILocalServiceAdapterTestService>(serviceProvider => new LocalServiceAdapterTestService()); ILocalServiceAdapterTestService obj = adapter.GetProxyObject(new Castle.DynamicProxy.ProxyGenerator())(null) as ILocalServiceAdapterTestService; obj.ShowInfo(); obj.ShowError("haha"); await obj.Run(); var result = await obj.RunAddAsync(1, 2); Assert.AreEqual(3, result); result = obj.Add(10, 20); Assert.AreEqual(30, result); }
public async Task TestServiceManagerAsync() { IServiceCollection services = new ServiceCollection(); services.AddLocalService <ILocalServiceAdapterTestService, LocalServiceAdapterTestService>(ServiceLifetime.Scoped); var provider = services.BuildServiceProvider(); ILocalServiceAdapterTestService obj = provider.GetService <ILocalServiceAdapterTestService>(); obj.ShowInfo(); obj.ShowError("haha"); await obj.Run(); var result = await obj.RunAddAsync(1, 2); Assert.AreEqual(3, result); result = obj.Add(10, 20); Assert.AreEqual(30, result); }