public void HighLoad() { var hs = new HostServer(14910); hs.Initialize(); var mvc = (MvcFactory)hs.Container.Get <IMvcFactory>(); mvc.Register(typeof(TestAction).Assembly); var tasks = new List <Task>(); for (var i = 0; i < 20; i++) { for (var j = 0; j < 4; j++) { tasks.Add(Task.Run(() => { hs.Call("/test/best"); })); } Console.WriteLine(i); Thread.Sleep(200); } Task.WaitAll(tasks.ToArray()); Console.WriteLine(mvc.GetMetric("action.pool.count")); Console.WriteLine(TestAction.creates); Assert.Greater(10, mvc.GetMetric("action.pool.count").ToInt()); Assert.Greater(10, TestAction.creates); }
private static int Execute(ServerParameters arg) { var config = arg.BuildServerConfig(); EnsureRequiredApplications(arg,config); config.DllFolder = EnvironmentInfo.ResolvePath("@repos@/.build/bin/all"); var command = arg.Get("command", ""); if (string.IsNullOrWhiteSpace(command)) { Console.WriteLine("LOGLEVEL " + config.LogLevel); } var hostServer = new HostServer(config); hostServer.Initialize(); var consoleContext = new ConsoleContext { Container = hostServer.Container, Parameters = arg }; var listener = new ConsoleListener(consoleContext); if (!string.IsNullOrWhiteSpace(command)) { var task = listener.Call(command); task.Wait(); } else { LogHostInfo(arg, config); hostServer.Start(); Console.WriteLine("LOGLEVEL " + config.LogLevel); listener.Log = hostServer.Container.Get<ILoggyManager>().Get("console"); listener.Run(); hostServer.Stop(); } return 0; }
public void Setup() { host = new HostServer(14910); host.Initialize(); host.Container.Get <IMvcFactory>().Register(typeof(ApiExecuteAction)); host.Container.Register(host.Container.NewComponent <IApi, Api>(Lifestyle.Pooled)); host.Factory.Register("/apir/execute", new ApiRequestHandler()); host.Start(); Thread.Sleep(100); cli = new HttpClient(); }
public void Setup() { this.host = new HostServer(14990); host.OnBeforeInitializeServices += c => { c.Register(c.NewComponent<IHostLogon,TestHostLogon>()); }; host.Initialize(); auth = host.Auth as DefaultHostAuthenticationProvider; Assert.NotNull(auth); Assert.NotNull(auth.HostLogonProvider); lp = auth.HostLogonProvider as DefaultHostLogonProvider; ls = auth.LoginSourceProvider as DefaultLoginSourceProvider; ls.Sources = new[] {new TestLoginSource()}; Assert.True(lp.HostLogons.OfType<TestHostLogon>().Any()); //this code is just tests that Auth uses logons from IoC lp.HostLogons = new[] {new TestHostLogon()}; //we require just one logon extension this.cl = new HttpClient(); host.Start(); Thread.Sleep(200); }
public void CanRunSingle() { var hs = new HostServer(14910); hs.Initialize(); var mvc = (MvcFactory)hs.Container.Get <IMvcFactory>(); mvc.Register(typeof(TestAction).Assembly); var result = hs.Call("/test/best"); Console.WriteLine(result); Assert.AreEqual("0", result); Assert.AreEqual(1, mvc.GetMetric("action.pool.count")); result = hs.Call("/test/best"); Assert.AreEqual("1", result); Assert.AreEqual(1, TestAction.creates); Assert.AreEqual(1, mvc.GetMetric("action.pool.count")); }
public void Setup() { this.host = new HostServer(14990); host.OnBeforeInitializeServices += c => { c.Register(c.NewComponent <IHostLogon, TestHostLogon>()); }; host.Initialize(); auth = host.Auth as DefaultHostAuthenticationProvider; Assert.NotNull(auth); Assert.NotNull(auth.HostLogonProvider); lp = auth.HostLogonProvider as DefaultHostLogonProvider; ls = auth.LoginSourceProvider as DefaultLoginSourceProvider; ls.Sources = new[] { new TestLoginSource() }; Assert.True(lp.HostLogons.OfType <TestHostLogon>().Any()); //this code is just tests that Auth uses logons from IoC lp.HostLogons = new[] { new TestHostLogon() }; //we require just one logon extension this.cl = new HttpClient(); host.Start(); Thread.Sleep(200); }
private static int Execute(ServerParameters arg) { var config = arg.BuildServerConfig(); EnsureRequiredApplications(arg, config); config.DllFolder = EnvironmentInfo.ResolvePath("@repos@/.build/bin/all"); var command = arg.Get("command", ""); if (string.IsNullOrWhiteSpace(command)) { Console.WriteLine("LOGLEVEL " + config.LogLevel); } var hostServer = new HostServer(config); hostServer.Initialize(); var consoleContext = new ConsoleContext { Container = hostServer.Container, Parameters = arg }; var listener = new ConsoleListener(consoleContext); if (!string.IsNullOrWhiteSpace(command)) { var task = listener.Call(command); task.Wait(); } else { LogHostInfo(arg, config); hostServer.Start(); Console.WriteLine("LOGLEVEL " + config.LogLevel); listener.Log = hostServer.Container.Get <ILoggyManager>().Get("console"); listener.Run(); hostServer.Stop(); } return(0); }