Resolve test application paths more robustly
This fixes tests on Mono for full framework
This commit is contained in:
parent
867b3b42cc
commit
6b6c658f6c
|
|
@ -12,8 +12,7 @@ namespace Microsoft.AspNetCore.Localization.FunctionalTests
|
|||
{
|
||||
public class LocalizationSampleTest
|
||||
{
|
||||
private static readonly string _applicationPath = Path.GetFullPath(
|
||||
Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "..", "..", "..", "..", "..", "..", "samples", "LocalizationSample"));
|
||||
private static readonly string _applicationPath = Path.Combine("samples", "LocalizationSample");
|
||||
|
||||
[ConditionalTheory]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ namespace Microsoft.AspNetCore.Localization.FunctionalTests
|
|||
{
|
||||
public class LocalizationTest
|
||||
{
|
||||
private static readonly string _applicationPath = Path.GetFullPath(
|
||||
Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "..", "..", "..", "..", "..", "LocalizationWebsite"));
|
||||
private static readonly string _applicationPath = Path.Combine("test", "LocalizationWebsite");
|
||||
|
||||
[ConditionalTheory]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Testing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Localization.FunctionalTests
|
||||
|
|
@ -17,7 +19,27 @@ namespace Microsoft.AspNetCore.Localization.FunctionalTests
|
|||
|
||||
public TestRunner(string applicationPath)
|
||||
{
|
||||
_applicationPath = applicationPath;
|
||||
_applicationPath = Path.Combine(ResolveRootFolder(PlatformServices.Default.Application.ApplicationBasePath), applicationPath);
|
||||
}
|
||||
|
||||
private static string ResolveRootFolder(string projectFolder)
|
||||
{
|
||||
var di = new DirectoryInfo(projectFolder);
|
||||
|
||||
while (di.Parent != null)
|
||||
{
|
||||
var globalJsonPath = Path.Combine(di.FullName, "global.json");
|
||||
|
||||
if (File.Exists(globalJsonPath))
|
||||
{
|
||||
return di.FullName;
|
||||
}
|
||||
|
||||
di = di.Parent;
|
||||
}
|
||||
|
||||
// If we don't find any files then make the project folder the root
|
||||
return projectFolder;
|
||||
}
|
||||
|
||||
private async Task<string> RunTestAndGetResponse(
|
||||
|
|
|
|||
Loading…
Reference in New Issue