mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Move TryGetSolutionDirectoryInfo in test utils
This commit is contained in:
@@ -143,6 +143,7 @@ namespace BTCPayServer.Tests
|
|||||||
_Host = new WebHostBuilder()
|
_Host = new WebHostBuilder()
|
||||||
.UseConfiguration(conf)
|
.UseConfiguration(conf)
|
||||||
.UseContentRoot(FindBTCPayServerDirectory())
|
.UseContentRoot(FindBTCPayServerDirectory())
|
||||||
|
.UseWebRoot(Path.Combine(FindBTCPayServerDirectory(), "wwwroot"))
|
||||||
.ConfigureServices(s =>
|
.ConfigureServices(s =>
|
||||||
{
|
{
|
||||||
s.AddLogging(l =>
|
s.AddLogging(l =>
|
||||||
@@ -267,7 +268,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
private string FindBTCPayServerDirectory()
|
private string FindBTCPayServerDirectory()
|
||||||
{
|
{
|
||||||
var solutionDirectory = LanguageService.TryGetSolutionDirectoryInfo(Directory.GetCurrentDirectory());
|
var solutionDirectory = TestUtils.TryGetSolutionDirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
return Path.Combine(solutionDirectory.FullName, "BTCPayServer");
|
return Path.Combine(solutionDirectory.FullName, "BTCPayServer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,22 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.AspNetCore.Http.Internal;
|
using Microsoft.AspNetCore.Http.Internal;
|
||||||
#endif
|
#endif
|
||||||
using Xunit.Sdk;
|
using Xunit.Sdk;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace BTCPayServer.Tests
|
namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
public static class TestUtils
|
public static class TestUtils
|
||||||
{
|
{
|
||||||
|
public static DirectoryInfo TryGetSolutionDirectoryInfo(string currentPath = null)
|
||||||
|
{
|
||||||
|
var directory = new DirectoryInfo(
|
||||||
|
currentPath ?? Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetFiles("*.sln").Any())
|
||||||
|
{
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return directory;
|
||||||
|
}
|
||||||
public static FormFile GetFormFile(string filename, string content)
|
public static FormFile GetFormFile(string filename, string content)
|
||||||
{
|
{
|
||||||
File.WriteAllText(filename, content);
|
File.WriteAllText(filename, content);
|
||||||
|
|||||||
@@ -39,11 +39,6 @@ namespace BTCPayServer.Services
|
|||||||
#else
|
#else
|
||||||
var path = environment.WebRootPath;
|
var path = environment.WebRootPath;
|
||||||
#endif
|
#endif
|
||||||
if (string.IsNullOrEmpty(path))
|
|
||||||
{
|
|
||||||
//test environment
|
|
||||||
path = Path.Combine(TryGetSolutionDirectoryInfo().FullName,"BTCPayServer", "wwwroot");
|
|
||||||
}
|
|
||||||
path = Path.Combine(path, "locales");
|
path = Path.Combine(path, "locales");
|
||||||
var files = Directory.GetFiles(path, "*.json");
|
var files = Directory.GetFiles(path, "*.json");
|
||||||
var result = new List<Language>();
|
var result = new List<Language>();
|
||||||
@@ -58,17 +53,6 @@ namespace BTCPayServer.Services
|
|||||||
|
|
||||||
_languages = result.ToArray();
|
_languages = result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DirectoryInfo TryGetSolutionDirectoryInfo(string currentPath = null)
|
|
||||||
{
|
|
||||||
var directory = new DirectoryInfo(
|
|
||||||
currentPath ?? Directory.GetCurrentDirectory());
|
|
||||||
while (directory != null && !directory.GetFiles("*.sln").Any())
|
|
||||||
{
|
|
||||||
directory = directory.Parent;
|
|
||||||
}
|
|
||||||
return directory;
|
|
||||||
}
|
|
||||||
public Language[] GetLanguages()
|
public Language[] GetLanguages()
|
||||||
{
|
{
|
||||||
return _languages;
|
return _languages;
|
||||||
|
|||||||
Reference in New Issue
Block a user