UserAppService_Tests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Microsoft.EntityFrameworkCore;
  2. using Shouldly;
  3. using VberAdmin.BaseSystem.Users;
  4. using VberZero.AppService.Base.Dto;
  5. using VberZero.AppService.Users.Dto;
  6. using Xunit;
  7. namespace VberAdmin.Tests.Users;
  8. public class UserAppService_Tests : VberAdminTestBase
  9. {
  10. private readonly IUserAppService _userAppService;
  11. public UserAppService_Tests()
  12. {
  13. _userAppService = Resolve<IUserAppService>();
  14. }
  15. [Fact]
  16. public async Task GetUsers_Test()
  17. {
  18. // Act
  19. var output = await _userAppService.GetAll(new VzPagedRequestDto() { MaxResultCount = 20, SkipCount = 0 });
  20. // Assert
  21. output.Items.Count.ShouldBeGreaterThan(0);
  22. }
  23. [Fact]
  24. public async Task CreateUser_Test()
  25. {
  26. // Act
  27. await _userAppService.Create(
  28. new CreateUserDto
  29. {
  30. EmailAddress = "john@volosoft.com",
  31. IsActive = true,
  32. Name = "John",
  33. Surname = "Nash",
  34. Password = "123qwe",
  35. UserName = "john.nash"
  36. });
  37. await UsingDbContextAsync(async context =>
  38. {
  39. var johnNashUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "john.nash");
  40. johnNashUser.ShouldNotBeNull();
  41. });
  42. }
  43. }