Hospital Management internal project. Build with Abp.io architecture.
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.

46 lines
1.5 KiB

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