diff --git a/Volo.Abp.sln b/Volo.Abp.sln index bf4b02fdf9..84dc802b22 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -184,6 +184,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Mvc.UI. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo", "test\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj", "{57E29185-6DAF-4A41-8CE0-3F07EE3E289A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests", "test\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj", "{869F7453-7DDC-4915-B92C-7861466AB68B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -514,6 +516,10 @@ Global {57E29185-6DAF-4A41-8CE0-3F07EE3E289A}.Debug|Any CPU.Build.0 = Debug|Any CPU {57E29185-6DAF-4A41-8CE0-3F07EE3E289A}.Release|Any CPU.ActiveCfg = Release|Any CPU {57E29185-6DAF-4A41-8CE0-3F07EE3E289A}.Release|Any CPU.Build.0 = Release|Any CPU + {869F7453-7DDC-4915-B92C-7861466AB68B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {869F7453-7DDC-4915-B92C-7861466AB68B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {869F7453-7DDC-4915-B92C-7861466AB68B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {869F7453-7DDC-4915-B92C-7861466AB68B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -602,6 +608,7 @@ Global {86A3BB43-8FA2-4CC2-BAD0-A86C6C9D9585} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {7E0517E0-AE09-4E10-8469-308F065F2F43} = {447C8A77-E5F0-4538-8687-7383196D04EA} {57E29185-6DAF-4A41-8CE0-3F07EE3E289A} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {869F7453-7DDC-4915-B92C-7861466AB68B} = {447C8A77-E5F0-4538-8687-7383196D04EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMvcTestBase.cs b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMvcTestBase.cs index ee5165e4f4..cde2871e1b 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMvcTestBase.cs +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMvcTestBase.cs @@ -20,7 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc .UseContentRoot(contentRootPath); } - private string CalculateContentRootPath(string projectFileName, string contentPath) + private static string CalculateContentRootPath(string projectFileName, string contentPath) { var currentDirectory = Directory.GetCurrentDirectory(); while (!ContainsFile(currentDirectory, projectFileName)) @@ -31,7 +31,7 @@ namespace Volo.Abp.AspNetCore.Mvc return Path.Combine(currentDirectory, contentPath); } - private bool ContainsFile(string currentDirectory, string projectFileName) + private static bool ContainsFile(string currentDirectory, string projectFileName) { return Directory .GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly) diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Startup.cs b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Startup.cs index 453ae00295..458bbd8827 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Startup.cs +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Startup.cs @@ -15,7 +15,6 @@ namespace Volo.Abp.AspNetCore.Mvc options.UseAutofac(); }); - //TODO: This is needed because ASP.NET Core does not use IServiceProviderFactory! return services.BuildServiceProviderFromFactory(); } diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj new file mode 100644 index 0000000000..9e09db1387 --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests.csproj @@ -0,0 +1,51 @@ + + + + netcoreapp2.0 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests + Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests + true + true + false + false + false + true + true + PackageReference + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + + + + + + diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs new file mode 100644 index 0000000000..9ced6317ec --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestBase.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore.Hosting; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo +{ + public abstract class AbpAspNetCoreMvcUiBootstrapDemoTestBase : AbpAspNetCoreTestBase + { + protected override IWebHostBuilder CreateWebHostBuilder() + { + return base.CreateWebHostBuilder() + .UseContentRoot(CalculateContentRootPath()); + } + + private static string CalculateContentRootPath() + { + return CalculateContentRootPath( + "Volo.Abp.sln", + string.Format( + "test{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo", + Path.DirectorySeparatorChar + ) + ); + } + + private static string CalculateContentRootPath( + string testFileNameInTheRootFolder, + string relativeContentPath) + { + var currentDirectory = Directory.GetCurrentDirectory(); + while (!ContainsFile(currentDirectory, testFileNameInTheRootFolder)) + { + currentDirectory = new DirectoryInfo(currentDirectory).Parent.FullName; + } + + if (!relativeContentPath.IsNullOrWhiteSpace()) + { + currentDirectory = Path.Combine(currentDirectory, relativeContentPath); + } + + return currentDirectory; + } + + private static bool ContainsFile(string currentDirectory, string projectFileName) + { + return Directory + .GetFiles(currentDirectory, "*.*", SearchOption.TopDirectoryOnly) + .Any(f => Path.GetFileName(f) == projectFileName); + } + } +} \ No newline at end of file diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestModule.cs b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestModule.cs new file mode 100644 index 0000000000..920571f4f0 --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/AbpAspNetCoreMvcUiBootstrapDemoTestModule.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.TestBase; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo +{ + [DependsOn( + typeof(AbpAspNetCoreMvcUiBootstrapDemoModule), + typeof(AbpAspNetCoreTestBaseModule) + )] + public class AbpAspNetCoreMvcUiBootstrapDemoTestModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/Components/Card_Tests.cs b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/Components/Card_Tests.cs new file mode 100644 index 0000000000..8c7cce61e2 --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/Components/Card_Tests.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using Shouldly; +using Xunit; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Components +{ + public class Card_Tests : AbpAspNetCoreMvcUiBootstrapDemoTestBase + { + [Fact] + public async Task Index() + { + var result = await GetResponseAsStringAsync("/Components/Cards"); + result.ShouldNotBeNullOrEmpty(); + } + } +} diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/TestStartup.cs b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/TestStartup.cs new file mode 100644 index 0000000000..da23c66e9f --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests/Volo/Abp/AspNetCore/Mvc/UI/Bootstrap/Demo/TestStartup.cs @@ -0,0 +1,26 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo +{ + public class TestStartup + { + public IServiceProvider ConfigureServices(IServiceCollection services) + { + services.AddApplication(options => + { + options.UseAutofac(); + }); + + return services.BuildServiceProviderFromFactory(); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); + } + } +} \ No newline at end of file diff --git a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj index 44e7cedb0e..1fc7547d7e 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj +++ b/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj @@ -2,13 +2,14 @@ netcoreapp2.0 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + true + true + true + PackageReference + false - - <_ContentIncludedByDefault Remove="wwwroot\css\demo.css" /> - <_ContentIncludedByDefault Remove="wwwroot\css\demo.min.css" /> - - @@ -19,8 +20,4 @@ - - - -