private async Task InteropTestCase(string name)
        {
            using (var serverProcess = new WebsiteProcess(_serverPath, _output))
            {
                await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout);

                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 clientOutput = clientProcess.GetOutput();
                        var errorMessage = $@"Error while running client process. Process output:
======================================
{clientOutput}";
                        throw new InvalidOperationException(errorMessage, ex);
                    }
                }
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        private async Task InteropTestCase(string name)
        {
            using (var serverProcess = new WebsiteProcess(_serverPath, _output))
            {
                await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout);

                using (var clientProcess = new ClientProcess(_output, _clientPath, serverProcess.ServerPort, name))
                {
                    await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);

                    await clientProcess.Exited.TimeoutAfter(DefaultTimeout);

                    Assert.Equal(0, clientProcess.ExitCode);
                }
            }
        }