Added VirtualFileSystem_Tests that is failing

pull/1810/head
Halil İbrahim Kalkan 5 years ago
parent e0c27f411b
commit a187831b73

@ -77,6 +77,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
app.UseMiddleware<FakeAuthenticationMiddleware>();
app.UseAuthorization();

@ -12,9 +12,15 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="wwwroot\SampleFiles\**\*.*" />
<None Remove="wwwroot\SampleFiles\**\*.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.TestBase\Volo.Abp.AspNetCore.TestBase.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>

@ -8,6 +8,11 @@ using Volo.Abp.AspNetCore.TestBase;
namespace Volo.Abp.AspNetCore
{
public class AbpAspNetCoreTestBase : AbpAspNetCoreTestBase<Startup>
{
}
public abstract class AbpAspNetCoreTestBase<TStartup> : AbpAspNetCoreIntegratedTestBase<TStartup>
where TStartup : class
{

@ -0,0 +1,52 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.TestBase;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.AspNetCore
{
[DependsOn(
typeof(AbpAspNetCoreTestBaseModule),
typeof(AbpAspNetCoreModule),
typeof(AbpAutofacModule)
)]
public class AbpAspNetCoreTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAspNetCoreTestModule>();
//options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreTestModule>(FindProjectPath(hostingEnvironment));
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
}
private string FindProjectPath(IWebHostEnvironment hostEnvironment)
{
var directory = new DirectoryInfo(hostEnvironment.ContentRootPath);
while (directory != null && directory.Name != "Volo.Abp.AspNetCore.Tests")
{
directory = directory.Parent;
}
return directory?.FullName
?? throw new Exception("Could not find the project path by beginning from " + hostEnvironment.ContentRootPath + ", going through to parents and looking for Volo.Abp.AspNetCore.Tests");
}
}
}

@ -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
{
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddApplication<AbpAspNetCoreTestModule>(options =>
{
options.UseAutofac();
});
return services.BuildServiceProviderFromFactory();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}
}

@ -0,0 +1,19 @@
using System.Threading.Tasks;
using Shouldly;
using Xunit;
namespace Volo.Abp.AspNetCore.VirtualFileSystem
{
public class VirtualFileSystem_Tests : AbpAspNetCoreTestBase
{
[Fact]
public async Task Get_Virtual_File()
{
var result = await GetResponseAsStringAsync(
"/SampleFiles/test1.js"
);
result.ShouldBe("test1.js-content");
}
}
}
Loading…
Cancel
Save