SessionAppService_Tests.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Threading.Tasks;
  2. using Shouldly;
  3. using Xunit;
  4. using YGNT.Exam.Sessions;
  5. namespace YGNT.Exam.Tests.Sessions
  6. {
  7. public class SessionAppService_Tests : ExamTestBase
  8. {
  9. private readonly ISessionAppService _sessionAppService;
  10. public SessionAppService_Tests()
  11. {
  12. _sessionAppService = Resolve<ISessionAppService>();
  13. }
  14. [MultiTenantFact]
  15. public async Task Should_Get_Current_User_When_Logged_In_As_Host()
  16. {
  17. // Arrange
  18. LoginAsHostAdmin();
  19. // Act
  20. var output = await _sessionAppService.GetCurrentLoginInformations();
  21. // Assert
  22. var currentUser = await GetCurrentUserAsync();
  23. output.User.ShouldNotBe(null);
  24. output.User.Name.ShouldBe(currentUser.Name);
  25. output.User.Surname.ShouldBe(currentUser.Surname);
  26. output.Tenant.ShouldBe(null);
  27. }
  28. [Fact]
  29. public async Task Should_Get_Current_User_And_Tenant_When_Logged_In_As_Tenant()
  30. {
  31. // Act
  32. var output = await _sessionAppService.GetCurrentLoginInformations();
  33. // Assert
  34. var currentUser = await GetCurrentUserAsync();
  35. var currentTenant = await GetCurrentTenantAsync();
  36. output.User.ShouldNotBe(null);
  37. output.User.Name.ShouldBe(currentUser.Name);
  38. output.Tenant.ShouldNotBe(null);
  39. output.Tenant.Name.ShouldBe(currentTenant.Name);
  40. }
  41. }
  42. }