Skip to content

Commit 056a251

Browse files
committed
Fix tests broken during conversion
1 parent f513f8c commit 056a251

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/Microsoft.AspNetCore.Server.IntegrationTesting/xunit/TestProjectHelpers.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.xunit
99
{
1010
public class TestProjectHelpers
1111
{
12-
public static string GetProjectRoot()
13-
{
14-
var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath;
12+
private const string SolutionName = "Hosting.sln";
1513

16-
var directoryInfo = new DirectoryInfo(applicationBasePath);
17-
do
18-
{
19-
var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "project.json"));
20-
if (projectFileInfo.Exists)
21-
{
22-
return projectFileInfo.DirectoryName;
23-
}
14+
public static string GetSolutionRoot()
15+
{
16+
var applicationName = PlatformServices.Default.Application.ApplicationName;
17+
var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath;
2418

25-
directoryInfo = directoryInfo.Parent;
19+
var directoryInfo = new DirectoryInfo(applicationBasePath);
20+
do
21+
{
22+
var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, SolutionName));
23+
if (projectFileInfo.Exists)
24+
{
25+
return projectFileInfo.DirectoryName;
2626
}
27-
while (directoryInfo.Parent != null);
2827

29-
throw new Exception($"Project root could not be found using {applicationBasePath}");
28+
directoryInfo = directoryInfo.Parent;
3029
}
30+
while (directoryInfo.Parent != null);
31+
32+
throw new Exception($"Solution file {SolutionName} could not be found using {applicationBasePath}");
3133
}
3234
}
35+
}

test/Microsoft.AspNetCore.Hosting.FunctionalTests/ShutdownTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Diagnostics;
65
using System.IO;
7-
using System.Net.Http;
8-
using System.Threading.Tasks;
96
using Microsoft.AspNetCore.Server.IntegrationTesting;
107
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
118
using Microsoft.AspNetCore.Testing.xunit;
129
using Microsoft.Extensions.Logging;
1310
using Xunit;
14-
using Xunit.Sdk;
1511

1612
namespace Microsoft.AspNetCore.Hosting.FunctionalTests
1713
{
@@ -26,7 +22,7 @@ public void ShutdownTest()
2622
.AddConsole()
2723
.CreateLogger(nameof(ShutdownTest));
2824

29-
string applicationPath = Path.Combine(TestProjectHelpers.GetProjectRoot(), "..",
25+
var applicationPath = Path.Combine(TestProjectHelpers.GetSolutionRoot(), "test",
3026
"Microsoft.AspNetCore.Hosting.TestSites");
3127

3228
var deploymentParameters = new DeploymentParameters(

0 commit comments

Comments
 (0)