mirror of https://github.com/abpframework/abp.git
9 changed files with 178 additions and 12 deletions
@ -0,0 +1,51 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp2.0</TargetFramework> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests</AssemblyName> |
||||
|
<PackageId>Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Tests</PackageId> |
||||
|
<PreserveCompilationContext>true</PreserveCompilationContext> |
||||
|
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
||||
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
||||
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" /> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" /> |
||||
|
<PackageReference Include="System.Net.Http" Version="4.3.3" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" /> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Abp.AspNetCore.Tests\Volo.Abp.AspNetCore.Tests.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<!-- Below ItemGroup and Target tags are added according to https://github.com/aspnet/Hosting/issues/959#issuecomment-286351703 --> |
||||
|
|
||||
|
<!-- Solves Problem#2 (404 when executing service calls hosted in other assemblies) --> |
||||
|
<!-- https://github.com/Microsoft/vstest/issues/196.--> |
||||
|
<ItemGroup> |
||||
|
<None Update="xunit.runner.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
</None> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<!-- https://github.com/NuGet/Home/issues/4412. --> |
||||
|
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''"> |
||||
|
<ItemGroup> |
||||
|
<DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" /> |
||||
|
</Target> |
||||
|
|
||||
|
</Project> |
||||
@ -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<TestStartup> |
||||
|
{ |
||||
|
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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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<AbpAspNetCoreMvcUiBootstrapDemoTestModule>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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<AbpAspNetCoreMvcUiBootstrapDemoTestModule>(options => |
||||
|
{ |
||||
|
options.UseAutofac(); |
||||
|
}); |
||||
|
|
||||
|
return services.BuildServiceProviderFromFactory(); |
||||
|
} |
||||
|
|
||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
||||
|
{ |
||||
|
app.InitializeApplication(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue