public async Task ActivateUserAccount_SendsEmailWithViewUserUrl() { // Arrange var builder = new UnauthenticatedUserControllerBuilder(); A.CallTo(() => builder.UserManager.ConfirmEmailAsync(A<string>._, A<string>._)) .Returns(IdentityResult.Success); var userId = Guid.NewGuid(); var user = new User(userId.ToString(), "FirstName", "SecondName", "*****@*****.**"); var competentAuthorityUser = A.Fake<CompetentAuthorityUser>(); A.CallTo(() => competentAuthorityUser.User) .Returns(user); A.CallTo(() => competentAuthorityUser.UserStatus) .Returns(UserStatus.Pending); A.CallTo(() => builder.GetAdminUserDataAccess.GetAdminUserOrDefault(userId)) .Returns(competentAuthorityUser); string viewUserUrl = "http://localhost/EditUser/abc"; var viewUserRoute = A.Fake<ViewCompetentAuthorityUserRoute>(); A.CallTo(() => viewUserRoute.GenerateUrl()) .Returns(viewUserUrl); var activatedUserAccountData = new ActivatedUserAccountData { Id = userId, ViewUserRoute = viewUserRoute }; var controller = builder.Build(); // Act await controller.ActivateUserAccount(activatedUserAccountData); // Assert A.CallTo(() => builder.EmailService.SendInternalUserAccountActivated(A<string>._, A<string>._, A<string>._, viewUserUrl)) .MustHaveHappened(); }
public async Task ActivateUserAccount_SendsEmailToCompetentAuthorityEmailAddress() { // Arrange var builder = new UnauthenticatedUserControllerBuilder(); A.CallTo(() => builder.UserManager.ConfirmEmailAsync(A<string>._, A<string>._)) .Returns(IdentityResult.Success); var userId = Guid.NewGuid(); string emailAddress = "*****@*****.**"; var competentAuthority = new UKCompetentAuthority( A.Dummy<Guid>(), "EA", "EA", A.Dummy<Country>(), emailAddress); var competentAuthorityUser = A.Fake<CompetentAuthorityUser>(); A.CallTo(() => competentAuthorityUser.CompetentAuthority) .Returns(competentAuthority); A.CallTo(() => competentAuthorityUser.UserStatus) .Returns(UserStatus.Pending); A.CallTo(() => builder.GetAdminUserDataAccess.GetAdminUserOrDefault(userId)) .Returns(competentAuthorityUser); var viewUserRoute = A.Fake<ViewCompetentAuthorityUserRoute>(); var activatedUserAccountData = new ActivatedUserAccountData { Id = userId, ViewUserRoute = viewUserRoute }; var controller = builder.Build(); // Act await controller.ActivateUserAccount(activatedUserAccountData); // Assert A.CallTo(() => builder.EmailService.SendInternalUserAccountActivated(emailAddress, A<string>._, A<string>._, A<string>._)) .MustHaveHappened(); }