mirror of https://github.com/abpframework/abp.git
7 changed files with 106 additions and 5 deletions
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.1</TargetFramework> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Blogging.Application\Volo.Blogging.Application.csproj" /> |
|||
<ProjectReference Include="..\Volo.Blogging.EntityFrameworkCore.Tests\Volo.Blogging.EntityFrameworkCore.Tests.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
[DependsOn( |
|||
typeof(BloggingApplicationModule), |
|||
typeof(BloggingEntityFrameworkCoreTestModule), |
|||
typeof(BloggingTestBaseModule))] |
|||
public class BloggingApplicationTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAlwaysAllowAuthorization(); |
|||
|
|||
services.AddAssemblyOf<BloggingApplicationTestModule>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public abstract class QaApplicationTestBase : BloggingTestBase<BloggingApplicationTestModule> |
|||
{ |
|||
protected virtual void UsingDbContext(Action<IBloggingDbContext> action) |
|||
{ |
|||
using (var dbContext = GetRequiredService<IBloggingDbContext>()) |
|||
{ |
|||
action.Invoke(dbContext); |
|||
} |
|||
} |
|||
|
|||
protected virtual T UsingDbContext<T>(Func<IBloggingDbContext, T> action) |
|||
{ |
|||
using (var dbContext = GetRequiredService<IBloggingDbContext>()) |
|||
{ |
|||
return action.Invoke(dbContext); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class BloggingTestData : ISingletonDependency |
|||
{ |
|||
public Guid Blog1Id { get; } = Guid.NewGuid(); |
|||
public Guid Blog1Post1Id { get; } = Guid.NewGuid(); |
|||
public Guid Blog1Post2Id { get; } = Guid.NewGuid(); |
|||
} |
|||
} |
|||
@ -1,12 +1,31 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Blogging.Blogs; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class BloggingTestDataBuilder : ITransientDependency |
|||
{ |
|||
private readonly BloggingTestData _testData; |
|||
private readonly IBlogRepository _blogRepository; |
|||
|
|||
public BloggingTestDataBuilder( |
|||
BloggingTestData testData, |
|||
IBlogRepository blogRepository) |
|||
{ |
|||
_testData = testData; |
|||
_blogRepository = blogRepository; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
//TODO
|
|||
AsyncHelper.RunSync(BuildAsync); |
|||
} |
|||
|
|||
public async Task BuildAsync() |
|||
{ |
|||
await _blogRepository.InsertAsync(new Blog(_testData.Blog1Id, "The First Blog", "blog-1")); |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue