private WebAppWrapper GetWebAppWrapper(DirectoryInfo srcDir, DirectoryInfo testsDir, string projectName) { if (srcDir == null || testsDir == null) { throw new Exception("srcDir and/or testsDir is null"); } var srcDirFullName = srcDir.FullName; var testsDirFullName = testsDir.FullName; var projectPath = $"{srcDirFullName}\\{projectName}"; var outputPath = $"{testsDirFullName}\\output\\{projectName}"; var propertiesPath = $"{projectPath}\\Properties"; var uriString = FileManager.GetAppUrlFromLaunchSettings(propertiesPath); var httpsPort = Convert.ToInt32(Regex.Match(uriString, @"\d+").Value); var wrapper = new WebAppWrapper { ProjectPath = projectPath, OutputPath = outputPath, PropertiesPath = propertiesPath, UriString = uriString, HttpsPort = httpsPort }; // teardown, publish and run the identity server web app in a process Setup(wrapper); return(wrapper); }
private ProcessWrapper PublishAndRun(WebAppWrapper parms) { // publish the web app to better control processes ProcManager.PublishWebApp(parms.ProjectPath, parms.OutputPath); // start process to ensure its port is actually listening var processWrapper = ProcManager.RunWebApp(parms.ProjectPath, parms.OutputPath, parms.UriString); return(processWrapper); }
public void Setup(WebAppWrapper webAppWrapper) { // ensure nothing is running on the port ProcManager.KillByPort(webAppWrapper.HttpsPort); // ensure the output directory to which we'll publish is empty DirManager.DeleteAndRecreate(webAppWrapper.OutputPath); // publish and run the specified webApp webAppWrapper.ProcWrapper = PublishAndRun(webAppWrapper); }
public void Teardown(WebAppWrapper webAppWrapper) { // (we don't delete the output here in case the tester wants to look at the logs) // dump the log var logFilename = $"{webAppWrapper.OutputPath}\\{GetNewLogfileName()}"; File.WriteAllText(logFilename, webAppWrapper.ProcWrapper.LoggingOutput.ToString()); // ensure nothing is running on the port ProcManager.KillByPort(webAppWrapper.HttpsPort); }
public ClientCredentialsFixture() { // path setup var assembly = Assembly.GetExecutingAssembly(); var solutionRoot = Directory.GetParent(assembly.Location)?.Parent?.Parent?.Parent?.Parent; var srcDir = solutionRoot?.GetDirectories().SingleOrDefault(x => x.Name == "src"); var testsDir = solutionRoot?.GetDirectories().SingleOrDefault(x => x.Name == "tests"); // IdentityServer setup // wrap all parameters, publish and start IdentityServer web app - // runs in a Process & listens on the port specified in launchSettings.json IdentityServerWrapper = GetWebAppWrapper(srcDir, testsDir, "IdentityServer"); // Web API setup // wrap all parameters, publish and start the Api web app - // runs in a Process & listens on the port specified in launchSettings.json WebApiWrapper = GetWebAppWrapper(srcDir, testsDir, "Api"); }