public void Run_Works() { var codeBlock = new NancyFxCodeBlock { Module = _sampleModule }; var opts = new NancyFxRunOpts {CodeBlock = codeBlock}; string htmlCode; RunResult result; using (var container = new ContainerUtils.DomainContainer()) { result = container.Execute(opts, typeof(NancyFxCodeHelper)); Assert.IsTrue(result.IsSuccess); using (WebClient client = new WebClient()) { string url = NancySelfHostingHelper.Instance.GenerateHostBaseUrl(opts.HostIndex); htmlCode = client.DownloadString(url); } } Assert.AreEqual("Hello World!", htmlCode); }
public static RunResult RunInThread(NancyFxCodeHelper codeHelper, NancyFxRunOpts runOpts) { RunResult result = null; try { //codeHelper.RequestedConsoleInput += CodeHelper_RequestedConsoleInput; var newThread = new Thread(() => { result = codeHelper.Run(runOpts); }); newThread.Start(); newThread.Join(TimeSpan.FromSeconds(10)); } finally { //codeHelper.RequestedConsoleInput -= CodeHelper_RequestedConsoleInput; } return result; }