2019-01-12 19:23:10 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2019-01-15 18:22:06 +08:00
|
|
|
|
namespace UnitTest
|
2019-01-12 19:23:10 +08:00
|
|
|
|
{
|
|
|
|
|
public static class TestHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得当前工程解决方案目录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrieveSolutionPath()
|
|
|
|
|
{
|
|
|
|
|
var dirSeparator = Path.DirectorySeparatorChar;
|
|
|
|
|
var paths = AppContext.BaseDirectory.SpanSplit($"{dirSeparator}.vs{dirSeparator}");
|
|
|
|
|
return paths.Count > 1 ? paths[0] : Path.Combine(AppContext.BaseDirectory, $"..{dirSeparator}..{dirSeparator}..{dirSeparator}..{dirSeparator}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="folder"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RetrievePath(string folder)
|
|
|
|
|
{
|
|
|
|
|
var soluFolder = RetrieveSolutionPath();
|
|
|
|
|
return Path.Combine(soluFolder, folder);
|
|
|
|
|
}
|
2019-01-15 18:22:06 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void CopyLicense()
|
|
|
|
|
{
|
|
|
|
|
var licFile = RetrievePath($"UnitTest{Path.DirectorySeparatorChar}License{Path.DirectorySeparatorChar}Longbow.lic");
|
|
|
|
|
|
|
|
|
|
var targetFile = Path.Combine(AppContext.BaseDirectory, "Longbow.lic");
|
|
|
|
|
if (!File.Exists(targetFile)) File.Copy(licFile, targetFile, true);
|
|
|
|
|
}
|
2019-01-12 19:23:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|