From 056a251b8c0653950a6eeab6ba9ca40e49b5b68c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 2 Feb 2017 10:17:49 -0800 Subject: [PATCH] Fix tests broken during conversion --- .../xunit/TestProjectHelpers.cs | 31 ++++++++++--------- .../ShutdownTests.cs | 6 +--- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/xunit/TestProjectHelpers.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting/xunit/TestProjectHelpers.cs index 76a3dc6d3e..697d628c88 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/xunit/TestProjectHelpers.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting/xunit/TestProjectHelpers.cs @@ -9,24 +9,27 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.xunit { public class TestProjectHelpers { - public static string GetProjectRoot() + private const string SolutionName = "Hosting.sln"; + + public static string GetSolutionRoot() + { + var applicationName = PlatformServices.Default.Application.ApplicationName; + var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath; + + var directoryInfo = new DirectoryInfo(applicationBasePath); + do { - var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath; - - var directoryInfo = new DirectoryInfo(applicationBasePath); - do + var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName)); + if (projectFileInfo.Exists) { - var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "project.json")); - if (projectFileInfo.Exists) - { - return projectFileInfo.DirectoryName; - } - - directoryInfo = directoryInfo.Parent; + return projectFileInfo.DirectoryName; } - while (directoryInfo.Parent != null); - throw new Exception($"Project root could not be found using {applicationBasePath}"); + directoryInfo = directoryInfo.Parent; } + while (directoryInfo.Parent != null); + + throw new Exception($"Solution file {SolutionName} could not be found using {applicationBasePath}"); } } +} diff --git a/test/Microsoft.AspNetCore.Hosting.FunctionalTests/ShutdownTests.cs b/test/Microsoft.AspNetCore.Hosting.FunctionalTests/ShutdownTests.cs index c794cbc9e8..65da149e3b 100644 --- a/test/Microsoft.AspNetCore.Hosting.FunctionalTests/ShutdownTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.FunctionalTests/ShutdownTests.cs @@ -1,17 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Diagnostics; using System.IO; -using System.Net.Http; -using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Logging; using Xunit; -using Xunit.Sdk; namespace Microsoft.AspNetCore.Hosting.FunctionalTests { @@ -26,7 +22,7 @@ namespace Microsoft.AspNetCore.Hosting.FunctionalTests .AddConsole() .CreateLogger(nameof(ShutdownTest)); - string applicationPath = Path.Combine(TestProjectHelpers.GetProjectRoot(), "..", + var applicationPath = Path.Combine(TestProjectHelpers.GetSolutionRoot(), "test", "Microsoft.AspNetCore.Hosting.TestSites"); var deploymentParameters = new DeploymentParameters(