Browse Source

register api for account module

pull/1440/head
Yunus Emre Kalkan 7 years ago
parent
commit
d3ad33ab5e
  1. 43
      modules/account/Volo.Abp.Account.sln
  2. 25
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.csproj
  3. 37
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AbpAccountApplicationContractsModule.cs
  4. 11
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/IAccountAppService.cs
  5. 10
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/AccountResource.cs
  6. 14
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
  7. 14
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json
  8. 25
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs
  9. 20
      modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.csproj
  10. 32
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModule.cs
  11. 27
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs
  12. 8
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountUrlNames.cs
  13. 17
      modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.csproj
  14. 19
      modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs
  15. 17
      modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.csproj
  16. 13
      modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AbpAccountHttpApiModule.cs
  17. 27
      modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs
  18. 1
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
  19. 1
      modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj
  20. 17
      modules/account/test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.csproj
  21. 10
      modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestBase.cs
  22. 51
      modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs
  23. 48
      modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs

43
modules/account/Volo.Abp.Account.sln

@ -1,13 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.29001.49
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B5881429-EFF7-4F30-8C0B-0AC41E36B74E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Account.Web", "src\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj", "{FCAC4354-7B13-4A91-A2F4-04D00F253C91}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Web.IdentityServer", "src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj", "{841C216F-B0E9-472C-BC19-2C31ADF0664F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Account.Web.IdentityServer", "src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj", "{841C216F-B0E9-472C-BC19-2C31ADF0664F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Application", "src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj", "{17251488-053D-42BA-B430-2428082E3D9E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Application.Contracts", "src\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj", "{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.HttpApi", "src\Volo.Abp.Account.HttpApi\Volo.Abp.Account.HttpApi.csproj", "{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.HttpApi.Client", "src\Volo.Abp.Account.HttpApi.Client\Volo.Abp.Account.HttpApi.Client.csproj", "{7BCA5955-B3F6-41E8-9D5D-D115195C6098}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{12FAE513-7575-4235-89DF-277BA1A3B098}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Application.Tests", "test\Volo.Abp.Account.Application.Tests\Volo.Abp.Account.Application.Tests.csproj", "{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -23,6 +35,26 @@ Global
{841C216F-B0E9-472C-BC19-2C31ADF0664F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{841C216F-B0E9-472C-BC19-2C31ADF0664F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{841C216F-B0E9-472C-BC19-2C31ADF0664F}.Release|Any CPU.Build.0 = Release|Any CPU
{17251488-053D-42BA-B430-2428082E3D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17251488-053D-42BA-B430-2428082E3D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17251488-053D-42BA-B430-2428082E3D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17251488-053D-42BA-B430-2428082E3D9E}.Release|Any CPU.Build.0 = Release|Any CPU
{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B}.Release|Any CPU.Build.0 = Release|Any CPU
{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E}.Release|Any CPU.Build.0 = Release|Any CPU
{7BCA5955-B3F6-41E8-9D5D-D115195C6098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BCA5955-B3F6-41E8-9D5D-D115195C6098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BCA5955-B3F6-41E8-9D5D-D115195C6098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BCA5955-B3F6-41E8-9D5D-D115195C6098}.Release|Any CPU.Build.0 = Release|Any CPU
{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -30,6 +62,11 @@ Global
GlobalSection(NestedProjects) = preSolution
{FCAC4354-7B13-4A91-A2F4-04D00F253C91} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{841C216F-B0E9-472C-BC19-2C31ADF0664F} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{17251488-053D-42BA-B430-2428082E3D9E} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{715B4DE5-47B4-4C99-A53A-D10FBBE7F48B} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{EBF0C2B3-14CB-4DFC-9753-ECBF959CBA2E} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{7BCA5955-B3F6-41E8-9D5D-D115195C6098} = {B5881429-EFF7-4F30-8C0B-0AC41E36B74E}
{356EAC51-5D55-4852-A8A5-2F90EAC8DAE3} = {12FAE513-7575-4235-89DF-277BA1A3B098}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B054393-D2B2-4EA8-8A15-D60CBCF3E7A9}

25
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.csproj

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.Application.Contracts</AssemblyName>
<PackageId>Volo.Abp.Account.Application.Contracts</PackageId>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Volo\Abp\Account\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<None Remove="Volo\Abp\Account\Localization\Resources\en.json" />
<None Remove="Volo\Abp\Account\Localization\Resources\zh-Hans.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
</ItemGroup>
</Project>

37
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AbpAccountApplicationContractsModule.cs

@ -0,0 +1,37 @@
using Volo.Abp.Account.Localization;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Account
{
[DependsOn(
typeof(AbpIdentityApplicationContractsModule)
)]
public class AbpAccountApplicationContractsModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountApplicationContractsModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<AccountResource>("en")
.AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Volo/Abp/Account/Localization/Resources");
});
Configure<ExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace("Volo.Account", typeof(AccountResource));
});
}
}
}

11
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/IAccountAppService.cs

@ -0,0 +1,11 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace Volo.Abp.Account
{
public interface IAccountAppService : IApplicationService
{
Task<IdentityUserDto> RegisterAsync(RegisterDto input);
}
}

10
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/AccountResource.cs

@ -0,0 +1,10 @@
using Volo.Abp.Localization;
namespace Volo.Abp.Account.Localization
{
[LocalizationResourceName("AbpAccount")]
public class AccountResource
{
}
}

14
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json

@ -0,0 +1,14 @@
{
"culture": "en",
"texts": {
"PasswordReset": "Password Reset",
"PasswordResetInfoInEmail": "We received an account recovery request! If you initiated this request, click the following link to reset your password.",
"ResetMyPassword": "Reset my password",
"NotAMemberYet": "Not a member yet?",
"OrSignInWith": "Or sign in with",
"EmailConfirmation": "Email Confirmation",
"EmailConfirmationInfoInEmail": "Please confirm your email address by clicking the following link.",
"ConfirmMyEmail": "Confirm my email address",
"Volo.Account:InvalidEmailAddress": "Can not find the given email address: {Email}"
}
}

14
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json

@ -0,0 +1,14 @@
{
"culture": "zh-Hans",
"texts": {
"PasswordReset": "重设密码",
"PasswordResetInfoInEmail": "我们收到了帐户恢复请求!如果您发起了此请求,请单击以下链接以重置密码.",
"ResetMyPassword": "重置我的密码",
"NotAMemberYet": "还不是会员?",
"OrSignInWith": "或者登录",
"EmailConfirmation": "邮件确认",
"EmailConfirmationInfoInEmail": "请点击以下链接确认您的电子邮件地址.",
"ConfirmMyEmail": "确认我的电子邮件地址",
"Volo.Account:InvalidEmailAddress": "找不到给定的电子邮件地址:{Email}"
}
}

25
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs

@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Identity;
namespace Volo.Abp.Account
{
public class RegisterDto
{
[Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)]
public string UserName { get; set; }
[Required]
[EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)]
public string EmailAddress { get; set; }
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DataType(DataType.Password)]
public string Password { get; set; }
[Required]
public string AppName { get; set; }
}
}

20
modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.Application</AssemblyName>
<PackageId>Volo.Abp.Account.Application</PackageId>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Encodings.Web" Version="4.5.0" />
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Emailing\Volo.Abp.Emailing.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.UI.Navigation\Volo.Abp.UI.Navigation.csproj" />
</ItemGroup>
</Project>

32
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModule.cs

@ -0,0 +1,32 @@
using Volo.Abp.Emailing;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.Ui.Navigation.Urls;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Account
{
[DependsOn(
typeof(AbpAccountApplicationContractsModule),
typeof(AbpEmailingModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpUiNavigationModule)
)]
public class AbpAccountApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountApplicationModule>();
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].Urls[AccountUrlNames.PasswordReset] = "Account/ResetPassword";
options.Applications["MVC"].Urls[AccountUrlNames.EmailConfirmation] = "Account/EmailConfirmation";
});
}
}
}

27
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs

@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Application.Services;
using Volo.Abp.Identity;
namespace Volo.Abp.Account
{
public class AccountAppService : ApplicationService, IAccountAppService
{
protected IdentityUserManager UserManager { get; }
public AccountAppService(
IdentityUserManager userManager)
{
UserManager = userManager;
}
public async Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.EmailAddress, CurrentTenant.Id);
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
}
}

8
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountUrlNames.cs

@ -0,0 +1,8 @@
namespace Volo.Abp.Account
{
public static class AccountUrlNames
{
public const string PasswordReset = "Abp.Account.PasswordReset";
public const string EmailConfirmation = "Abp.Account.EmailConfirmation";
}
}

17
modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo.Abp.Account.HttpApi.Client.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.HttpApi.Client</AssemblyName>
<PackageId>Volo.Abp.Account.HttpApi.Client</PackageId>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Http.Client\Volo.Abp.Http.Client.csproj" />
</ItemGroup>
</Project>

19
modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs

@ -0,0 +1,19 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
namespace Volo.Abp.Account
{
[DependsOn(
typeof(AbpAccountApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class AbpAccountHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "Account";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(typeof(AbpAccountApplicationContractsModule).Assembly, RemoteServiceName);
}
}
}

17
modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.HttpApi</AssemblyName>
<PackageId>Volo.Abp.Account.HttpApi</PackageId>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
</ItemGroup>
</Project>

13
modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AbpAccountHttpApiModule.cs

@ -0,0 +1,13 @@
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace Volo.Abp.Account
{
[DependsOn(
typeof(AbpAccountApplicationContractsModule),
typeof(AbpAspNetCoreMvcModule))]
public class AbpAccountHttpApiModule : AbpModule
{
}
}

27
modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs

@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Identity;
namespace Volo.Abp.Account
{
[RemoteService]
[Area("account")]
[Route("api/account")]
public class AccountController : AbpController, IAccountAppService
{
private readonly IAccountAppService _accountAppService;
public AccountController(IAccountAppService accountAppService)
{
_accountAppService = accountAppService;
}
[HttpPost]
[Route("register")]
public Task<IdentityUserDto> RegisterAsync(RegisterDto input)
{
return _accountAppService.RegisterAsync(input);
}
}
}

1
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs

@ -14,6 +14,7 @@ using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Account.Web
{
[DependsOn(
typeof(AbpAccountHttpApiModule),
typeof(AbpIdentityAspNetCoreModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule)
)]

1
modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj

@ -32,6 +32,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
<ProjectReference Include="..\Volo.Abp.Account.HttpApi\Volo.Abp.Account.HttpApi.csproj" />
</ItemGroup>
</Project>

17
modules/account/test/Volo.Abp.Account.Application.Tests/Volo.Abp.Account.Application.Tests.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\identity\test\Volo.Abp.Identity.Domain.Tests\Volo.Abp.Identity.Domain.Tests.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" />
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
</ItemGroup>
</Project>

10
modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestBase.cs

@ -0,0 +1,10 @@
namespace Volo.Abp.Account
{
public class AbpAccountApplicationTestBase : AbpIntegratedTest<AbpAccountApplicationTestModule>
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
}
}

51
modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs

@ -0,0 +1,51 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
namespace Volo.Abp.Account
{
[DependsOn(
typeof(AbpIdentityAspNetCoreModule),
typeof(AbpAccountApplicationModule),
typeof(AbpIdentityDomainTestModule)
)]
public class AbpAccountApplicationTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var sqliteConnection = CreateDatabaseAndGetConnection();
Configure<AbpDbContextOptions>(options =>
{
options.Configure(abpDbContextConfigurationContext =>
{
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
});
});
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(
new DbContextOptionsBuilder<IdentityDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
new PermissionManagementDbContext(
new DbContextOptionsBuilder<PermissionManagementDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
return connection;
}
}
}

48
modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AccountAppService_Tests.cs

@ -0,0 +1,48 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Shouldly;
using Volo.Abp.Identity;
using Xunit;
namespace Volo.Abp.Account.Pro.Application.Tests.Volo.Abp.Account
{
public class AccountAppService_Tests : AbpAccountApplicationTestBase
{
private readonly IAccountAppService _accountAppService;
private readonly IIdentityUserRepository _identityUserRepository;
private readonly ILookupNormalizer _lookupNormalizer;
private readonly IdentityUserManager _userManager;
public AccountAppService_Tests()
{
_accountAppService = GetRequiredService<IAccountAppService>();
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
_lookupNormalizer = GetRequiredService<ILookupNormalizer>();
_userManager = GetRequiredService<IdentityUserManager>();
}
[Fact]
public async Task RegisterAsync()
{
var registerDto = new RegisterDto()
{
UserName = "bob.lee",
EmailAddress = "bob.lee@abp.io",
Password = "P@ssW0rd",
AppName = "MVC"
};
await _accountAppService.RegisterAsync(registerDto);
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.Normalize("bob.lee"));
user.ShouldNotBeNull();
user.UserName.ShouldBe("bob.lee");
user.Email.ShouldBe("bob.lee@abp.io");
(await _userManager.CheckPasswordAsync(user, "P@ssW0rd")).ShouldBeTrue();
}
}
}
Loading…
Cancel
Save