You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

  1. using System.Threading.Tasks;
  2. using Shouldly;
  3. using Volo.Abp.Identity;
  4. using Xunit;
  5. namespace Shentun.Sms.Samples;
  6. /* This is just an example test class.
  7. * Normally, you don't test code of the modules you are using
  8. * (like IdentityUserManager here).
  9. * Only test your own domain services.
  10. */
  11. public class SampleDomainTests : SmsDomainTestBase
  12. {
  13. private readonly IIdentityUserRepository _identityUserRepository;
  14. private readonly IdentityUserManager _identityUserManager;
  15. public SampleDomainTests()
  16. {
  17. _identityUserRepository = GetRequiredService<IIdentityUserRepository>();
  18. _identityUserManager = GetRequiredService<IdentityUserManager>();
  19. }
  20. [Fact]
  21. public async Task Should_Set_Email_Of_A_User()
  22. {
  23. IdentityUser adminUser;
  24. /* Need to manually start Unit Of Work because
  25. * FirstOrDefaultAsync should be executed while db connection / context is available.
  26. */
  27. await WithUnitOfWorkAsync(async () =>
  28. {
  29. adminUser = await _identityUserRepository
  30. .FindByNormalizedUserNameAsync("ADMIN");
  31. await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
  32. await _identityUserRepository.UpdateAsync(adminUser);
  33. });
  34. adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
  35. adminUser.Email.ShouldBe("newemail@abp.io");
  36. }
  37. }