mirror of https://github.com/abpframework/abp.git
13 changed files with 22 additions and 53 deletions
@ -1,40 +1,6 @@ |
|||
using System.IO; |
|||
using System.Linq; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
public abstract class AspNetCoreMvcTestBase : AbpAspNetCoreTestBase<Program> |
|||
{ |
|||
protected override IHostBuilder CreateHostBuilder() |
|||
{ |
|||
var contentRootPath = CalculateContentRootPath( |
|||
"Volo.Abp.AspNetCore.Mvc.Tests.csproj", |
|||
string.Format( |
|||
"Volo{0}Abp{0}AspNetCore{0}App", |
|||
Path.DirectorySeparatorChar |
|||
) |
|||
); |
|||
|
|||
return base.CreateHostBuilder()?.UseContentRoot(contentRootPath); |
|||
} |
|||
|
|||
private static string CalculateContentRootPath(string projectFileName, string contentPath) |
|||
{ |
|||
var currentDirectory = Directory.GetCurrentDirectory(); |
|||
while (!ContainsFile(currentDirectory, projectFileName)) |
|||
{ |
|||
currentDirectory = new DirectoryInfo(currentDirectory).Parent.FullName; |
|||
} |
|||
|
|||
return Path.Combine(currentDirectory, contentPath); |
|||
} |
|||
|
|||
private static bool ContainsFile(string currentDirectory, string projectFileName) |
|||
{ |
|||
return Directory |
|||
.GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly) |
|||
.Any(f => Path.GetFileName(f) == projectFileName); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using MyCompanyName.MyProjectName; |
|||
using Volo.Abp.AspNetCore.TestBase; |
|||
|
|||
var builder = WebApplication.CreateBuilder(); |
|||
await builder.RunAbpModuleAsync<MyProjectNameWebTestModule>(); |
|||
|
|||
public partial class Program |
|||
{ |
|||
} |
|||
Loading…
Reference in new issue