Skip to content

Commit 71744b7

Browse files
committed
Changed test Startup with a workaround.
1 parent e1b2f5b commit 71744b7

File tree

1 file changed

+11
-2
lines changed
  • test/AbpCompanyName.AbpProjectName.Web.Tests

1 file changed

+11
-2
lines changed

test/AbpCompanyName.AbpProjectName.Web.Tests/Startup.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
using Abp.AspNetCore.TestBase;
55
using Abp.Dependency;
66
using AbpCompanyName.AbpProjectName.EntityFrameworkCore;
7+
using AbpCompanyName.AbpProjectName.Web.Controllers;
78
using Castle.MicroKernel.Registration;
89
using Microsoft.AspNetCore.Builder;
910
using Microsoft.AspNetCore.Hosting;
11+
using Microsoft.AspNetCore.Mvc.ApplicationParts;
1012
using Microsoft.EntityFrameworkCore;
1113
using Microsoft.Extensions.DependencyInjection;
1214
using Microsoft.Extensions.Logging;
@@ -19,10 +21,17 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
1921
{
2022
services.AddEntityFrameworkInMemoryDatabase();
2123

22-
services.AddMvc(options =>
24+
var mvc = services.AddMvc(options =>
2325
{
2426
options.AddAbp(); //Add ABP infrastructure to MVC
25-
}).AddControllersAsServices();
27+
});
28+
29+
//Workaround defined here: https://github.com/aspnet/Mvc/issues/4897#issuecomment-228093609
30+
var parts = mvc.PartManager.ApplicationParts;
31+
parts.Clear();
32+
parts.Add(new AssemblyPart(typeof(HomeController).Assembly));
33+
34+
mvc.AddControllersAsServices();
2635

2736
//Configure Abp and Dependency Injection
2837
return services.AddAbp(options =>

0 commit comments

Comments
 (0)