first commit
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Report</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\KonSoft.Report.Domain\KonSoft.Report.Domain.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Report.TestBase\KonSoft.Report.TestBase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,10 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
/* Inherit from this class for your domain layer tests. */
|
||||
public abstract class ReportDomainTestBase<TStartupModule> : ReportTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
[DependsOn(
|
||||
typeof(ReportDomainModule),
|
||||
typeof(ReportTestBaseModule)
|
||||
)]
|
||||
public class ReportDomainTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Report.Samples;
|
||||
|
||||
/* This is just an example test class.
|
||||
* Normally, you don't test code of the modules you are using
|
||||
* (like IdentityUserManager here).
|
||||
* Only test your own domain services.
|
||||
*/
|
||||
public abstract class SampleDomainTests<TStartupModule> : ReportDomainTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
private readonly IIdentityUserRepository _identityUserRepository;
|
||||
private readonly IdentityUserManager _identityUserManager;
|
||||
|
||||
protected SampleDomainTests()
|
||||
{
|
||||
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
|
||||
_identityUserManager = GetRequiredService<IdentityUserManager>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_Set_Email_Of_A_User()
|
||||
{
|
||||
IdentityUser adminUser;
|
||||
|
||||
/* Need to manually start Unit Of Work because
|
||||
* FirstOrDefaultAsync should be executed while db connection / context is available.
|
||||
*/
|
||||
await WithUnitOfWorkAsync(async () =>
|
||||
{
|
||||
adminUser = await _identityUserRepository
|
||||
.FindByNormalizedUserNameAsync("ADMIN");
|
||||
|
||||
await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
|
||||
await _identityUserRepository.UpdateAsync(adminUser);
|
||||
});
|
||||
|
||||
adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
|
||||
adminUser.Email.ShouldBe("newemail@abp.io");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user