30 lines
977 B
C#
30 lines
977 B
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Extensions.PlatformAbstractions;
|
|
|
|
namespace Microsoft.AspNetCore.WebSockets.Server.Test
|
|
{
|
|
public class Helpers
|
|
{
|
|
public static string GetApplicationPath(string projectName)
|
|
{
|
|
var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath;
|
|
|
|
var directoryInfo = new DirectoryInfo(applicationBasePath);
|
|
do
|
|
{
|
|
var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "WebSockets.sln"));
|
|
if (solutionFileInfo.Exists)
|
|
{
|
|
return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", projectName));
|
|
}
|
|
|
|
directoryInfo = directoryInfo.Parent;
|
|
}
|
|
while (directoryInfo.Parent != null);
|
|
|
|
throw new Exception($"Solution root could not be found using {applicationBasePath}");
|
|
}
|
|
}
|
|
}
|