Tests/ABPCMS.Tests/Users/UserAppService_Tests.cs
(完整代码) 1KBusing System.Data.Entity;
using System.Threading.Tasks;
using Abp.Application.Services.Dto;
using ABPCMS.Users;
using ABPCMS.Users.Dto;
using Shouldly;
using Xunit;
namespace ABPCMS.Tests.Users
{
public class UserAppService_Tests : ABPCMSTestBase
{
private readonly IUserAppService _userAppService;
public UserAppService_Tests()
{
_userAppService = Resolve<IUserAppService>();
}
[Fact]
public async Task GetUsers_Test()
{
//Act
var output = await _userAppService.GetAll(new PagedResultRequestDto { MaxResultCount = 20, SkipCount = 0 });
//Assert
output.Items.Count.ShouldBeGreaterThan(0);
}
[Fact]
public async Task CreateUser_Test()
{
//Act
await _userAppService.Create(
new CreateUserDto
{
EmailAddress = "john@volosoft.com",
IsActive = true,
Name = "John",
Surname = "Nash",
Password = "123qwe",
UserName = "john.nash",
RoleNames = new string[0]
});
await UsingDbContextAsync(async context =>
{
var johnNashUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "john.nash");
johnNashUser.ShouldNotBeNull();
});
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
