Fix tests broken during conversion

This commit is contained in:
Pranav K 2017-02-02 10:17:49 -08:00
parent f513f8ceac
commit 056a251b8c
2 changed files with 18 additions and 19 deletions

View File

@ -9,14 +9,17 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.xunit
{ {
public class TestProjectHelpers 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 applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath;
var directoryInfo = new DirectoryInfo(applicationBasePath); var directoryInfo = new DirectoryInfo(applicationBasePath);
do do
{ {
var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "project.json")); var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName));
if (projectFileInfo.Exists) if (projectFileInfo.Exists)
{ {
return projectFileInfo.DirectoryName; return projectFileInfo.DirectoryName;
@ -26,7 +29,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.xunit
} }
while (directoryInfo.Parent != null); while (directoryInfo.Parent != null);
throw new Exception($"Project root could not be found using {applicationBasePath}"); throw new Exception($"Solution file {SolutionName} could not be found using {applicationBasePath}");
} }
} }
} }

View File

@ -1,17 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved. // 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. // 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.Diagnostics;
using System.IO; using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Xunit; using Xunit;
using Xunit.Sdk;
namespace Microsoft.AspNetCore.Hosting.FunctionalTests namespace Microsoft.AspNetCore.Hosting.FunctionalTests
{ {
@ -26,7 +22,7 @@ namespace Microsoft.AspNetCore.Hosting.FunctionalTests
.AddConsole() .AddConsole()
.CreateLogger(nameof(ShutdownTest)); .CreateLogger(nameof(ShutdownTest));
string applicationPath = Path.Combine(TestProjectHelpers.GetProjectRoot(), "..", var applicationPath = Path.Combine(TestProjectHelpers.GetSolutionRoot(), "test",
"Microsoft.AspNetCore.Hosting.TestSites"); "Microsoft.AspNetCore.Hosting.TestSites");
var deploymentParameters = new DeploymentParameters( var deploymentParameters = new DeploymentParameters(