mirror of https://github.com/abpframework/abp.git
6 changed files with 147 additions and 1 deletions
@ -0,0 +1,30 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.Identity.Application.Tests</AssemblyName> |
|||
<PackageId>Volo.Abp.Identity.Application.Tests</PackageId> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.TestBase; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class AbpIdentityApplicationTestBase : AbpIntegratedTest<AbpIdentityApplicationTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[DependsOn(typeof(AbpIdentityApplicationModule), typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpAutofacModule))] |
|||
public class AbpIdentityApplicationTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpIdentityApplicationTestModule>(); |
|||
|
|||
services.AddEntityFrameworkInMemoryDatabase(); |
|||
|
|||
var databaseName = Guid.NewGuid().ToString(); |
|||
|
|||
services.Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.DbContextOptions.UseInMemoryDatabase(databaseName); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
SeedTestData(context); |
|||
} |
|||
|
|||
private static void SeedTestData(ApplicationInitializationContext context) |
|||
{ |
|||
using (var scope = context.ServiceProvider.CreateScope()) |
|||
{ |
|||
scope.ServiceProvider |
|||
.GetRequiredService<AbpIdentityTestDataBuilder>() |
|||
.Build(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Guids; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class AbpIdentityTestDataBuilder : ITransientDependency |
|||
{ |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IIdentityUserRepository _userRepository; |
|||
|
|||
public AbpIdentityTestDataBuilder( |
|||
IGuidGenerator guidGenerator, |
|||
IIdentityUserRepository userRepository) |
|||
{ |
|||
_guidGenerator = guidGenerator; |
|||
_userRepository = userRepository; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
_userRepository.Insert(new IdentityUser(_guidGenerator.Create(), "john.nash")); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Shouldly; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class IdentityUserAppService_Tests : AbpIdentityApplicationTestBase |
|||
{ |
|||
private readonly IIdentityUserAppService _identityUserAppService; |
|||
|
|||
public IdentityUserAppService_Tests() |
|||
{ |
|||
_identityUserAppService = ServiceProvider.GetRequiredService<IIdentityUserAppService>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task GetList() |
|||
{ |
|||
var result = await _identityUserAppService.GetListAsync(new PagedAndSortedResultRequestDto { MaxResultCount = 10 }); |
|||
result.TotalCount.ShouldBeGreaterThan(0); |
|||
result.Items.Count.ShouldBeGreaterThan(0); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue