private async Task InteropTestCase(string name) { using (var serverProcess = new WebsiteProcess(_serverPath, _output)) { try { await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout); } catch (Exception ex) { var errorMessage = $@"Error while running server process. Server ready: {serverProcess.IsReady} Server process output: ====================================== {serverProcess.GetOutput()} ======================================"; throw new InvalidOperationException(errorMessage, ex); } using (var clientProcess = new ClientProcess(_output, _clientPath, serverProcess.ServerPort, name)) { try { await clientProcess.WaitForReadyAsync().TimeoutAfter(DefaultTimeout); await clientProcess.WaitForExitAsync().TimeoutAfter(DefaultTimeout); Assert.Equal(0, clientProcess.ExitCode); } catch (Exception ex) { var errorMessage = $@"Error while running client process. Server ready: {serverProcess.IsReady} Client ready: {clientProcess.IsReady} Server process output: ====================================== {serverProcess.GetOutput()} ====================================== Client process output: ====================================== {clientProcess.GetOutput()} ======================================"; throw new InvalidOperationException(errorMessage, ex); } } } }
public async Task RunWebsiteAndCallWithClient_Success() { var projectDirectory = typeof(LinkerTests).Assembly .GetCustomAttributes <AssemblyMetadataAttribute>() .Single(a => a.Key == "ProjectDirectory") .Value; var tempPath = Path.GetTempPath(); var linkerTestsClientPath = Path.Combine(tempPath, "LinkerTestsClient"); var linkerTestsWebsitePath = Path.Combine(tempPath, "LinkerTestsWebsite"); EnsureDeleted(linkerTestsClientPath); EnsureDeleted(linkerTestsWebsitePath); try { using var websiteProcess = new WebsiteProcess(); using var clientProcess = new DotNetProcess(); try { var publishWebsiteTask = PublishAppAsync(projectDirectory + @"\..\..\testassets\LinkerTestsWebsite\LinkerTestsWebsite.csproj", linkerTestsWebsitePath); var publishClientTask = PublishAppAsync(projectDirectory + @"\..\..\testassets\LinkerTestsClient\LinkerTestsClient.csproj", linkerTestsClientPath); await Task.WhenAll(publishWebsiteTask, publishClientTask).TimeoutAfter(Timeout); websiteProcess.Start(Path.Combine(linkerTestsWebsitePath, "LinkerTestsWebsite.dll")); await websiteProcess.WaitForReadyAsync().TimeoutAfter(Timeout); clientProcess.Start(Path.Combine(linkerTestsClientPath, $"LinkerTestsClient.dll {websiteProcess.ServerPort}")); await clientProcess.WaitForExitAsync().TimeoutAfter(Timeout); Assert.AreEqual(0, clientProcess.ExitCode); } finally { Console.WriteLine("Website output:"); Console.WriteLine(websiteProcess.GetOutput()); Console.WriteLine("Client output:"); Console.WriteLine(clientProcess.GetOutput()); } } finally { EnsureDeleted(linkerTestsClientPath); EnsureDeleted(linkerTestsWebsitePath); } }