diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj index 8e0059cd4a..d014b869e4 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj @@ -2,17 +2,22 @@ netcoreapp2.0 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; Volo.Abp.AspNetCore.Mvc.Tests Volo.Abp.AspNetCore.Mvc.Tests + true true false false false + true + true + @@ -22,4 +27,23 @@ + + + + + + + PreserveNewest + + + + + + + + + + + + diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs index a1250001ad..213bdc175e 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs @@ -9,5 +9,10 @@ namespace Volo.Abp.AspNetCore.App { return Content("Index-Result"); } + + public ActionResult About() + { + return View(); + } } } diff --git a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/Views/Simple/About.cshtml b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/Views/Simple/About.cshtml new file mode 100644 index 0000000000..367267d4c0 --- /dev/null +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/Views/Simple/About.cshtml @@ -0,0 +1 @@ +

About

\ No newline at end of file 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 53b113b644..de69775fd5 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 @@ -1,9 +1,43 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore.Hosting; using Volo.Abp.AspNetCore.App; namespace Volo.Abp.AspNetCore.Mvc { public abstract class AspNetCoreMvcTestBase : AbpAspNetCoreTestBase { + protected override IWebHostBuilder CreateWebHostBuilder() + { + var contentRootPath = CalculateContentRootPath( + "Volo.Abp.AspNetCore.Mvc.Tests.csproj", + string.Format( + "Volo{0}Abp{0}AspNetCore{0}App", + Path.DirectorySeparatorChar + ) + ); + return base.CreateWebHostBuilder() + .UseContentRoot(contentRootPath); + } + + private 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 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.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs index 0847655db6..c6378f9034 100644 --- a/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs +++ b/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.AspNetCore.Mvc public class SimpleController_Tests : AspNetCoreMvcTestBase { [Fact] - public async Task ActionResult_Return_Type_ContentResult_Return_Value() + public async Task ActionResult_ContentResult() { var result = await GetResponseAsStringAsync( GetUrl(nameof(SimpleController.Index)) @@ -16,5 +16,15 @@ namespace Volo.Abp.AspNetCore.Mvc result.ShouldBe("Index-Result"); } + + [Fact] + public async Task ActionResult_ViewResult() + { + var result = await GetResponseAsStringAsync( + GetUrl(nameof(SimpleController.About)) + ); + + result.Trim().ShouldBe("

About

"); + } } }