예제 #1
0
        public async void AskPasswordRecoveryWithMailNotSent()
        {
            // Arrange
            var mockedUserManager = GetUserManager();

            mockedUserManager.FindByEmailAsync(Arg.Any <string>()).ReturnsForAnyArgs(new User {
                Id = "Id", Email = "email"
            });
            mockedUserManager.GeneratePasswordResetTokenAsync(Arg.Any <User>()).ReturnsForAnyArgs("token");
            var mockedSendgridService = GetSendgridService();

            mockedSendgridService.SendRecoveryEmail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).ReturnsForAnyArgs(false);

            IdentityService service = new IdentityService(mockedUserManager, GetSignInManager(), mockedSendgridService, GetAppSettings(), GetRefreshTokenService(), GetImageService());

            // Act
            var result = await service.AskPasswordRecovery("email");

            // Assert
            Assert.False(result.Succeeded);
            Assert.NotNull(result.Messages);
        }