UserAppService_Tests.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Data.Entity;
  2. using System.Threading.Tasks;
  3. using Abp.Application.Services.Dto;
  4. using WePlatform.BaseSystem.Users;
  5. using WePlatform.BaseSystem.Users.Dto;
  6. using IwbZero.AppServiceBase;
  7. using Shouldly;
  8. using Xunit;
  9. namespace WePlatform.Users
  10. {
  11. public class UserAppServiceTests : WePlatformTestBase
  12. {
  13. private readonly IUsersAppService _userAppService;
  14. public UserAppServiceTests()
  15. {
  16. _userAppService = Resolve<IUsersAppService>();
  17. }
  18. [Fact]
  19. public async Task GetUsers_Test()
  20. {
  21. //Act
  22. var output = await _userAppService.GetAll(new IwbPagedRequestDto { MaxResultCount = 20, SkipCount = 0 });
  23. //Assert
  24. output.Items.Count.ShouldBeGreaterThan(0);
  25. }
  26. [Fact]
  27. public async Task CreateUser_Test()
  28. {
  29. //Act
  30. await _userAppService.Create(
  31. new UserCreateDto
  32. {
  33. EmailAddress = "john@volosoft.com",
  34. IsActive = true,
  35. Name = "John",
  36. UserName = "john.nash",
  37. RoleNames = ""
  38. });
  39. await UsingDbContextAsync(async context =>
  40. {
  41. var johnNashUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "john.nash");
  42. johnNashUser.ShouldNotBeNull();
  43. });
  44. }
  45. }
  46. }