UserAppService_Tests.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Threading.Tasks;
  2. using Microsoft.EntityFrameworkCore;
  3. using Shouldly;
  4. using Xunit;
  5. using Abp.Application.Services.Dto;
  6. using YGNT.Exam.Users;
  7. using YGNT.Exam.Users.Dto;
  8. namespace YGNT.Exam.Tests.Users
  9. {
  10. public class UserAppService_Tests : ExamTestBase
  11. {
  12. private readonly IUserAppService _userAppService;
  13. public UserAppService_Tests()
  14. {
  15. _userAppService = Resolve<IUserAppService>();
  16. }
  17. [Fact]
  18. public async Task GetUsers_Test()
  19. {
  20. // Act
  21. var output = await _userAppService.GetAllAsync(new PagedUserResultRequestDto{MaxResultCount=20, SkipCount=0} );
  22. // Assert
  23. output.Items.Count.ShouldBeGreaterThan(0);
  24. }
  25. [Fact]
  26. public async Task CreateUser_Test()
  27. {
  28. // Act
  29. await _userAppService.CreateAsync(
  30. new CreateUserDto
  31. {
  32. EmailAddress = "john@volosoft.com",
  33. IsActive = true,
  34. Name = "John",
  35. Surname = "Nash",
  36. Password = "123qwe",
  37. UserName = "john.nash"
  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. }