public IHttpActionResult SendNewPassword(SendNewPasswordData command) { var validationResult = _commands.ValidateThatNewPasswordCanBeSent(command); if (!validationResult.IsValid) { return(Ok(ValidationExceptionResponse(validationResult.Errors))); } _commands.SendNewPassword(command); return(Ok(new { Result = "success" })); }
public void Invalid_PlayerId_Verification_Works() { _playerCommands = Container.Resolve <PlayerCommands>(); var e = Assert.Throws <RegoValidationException>( () => _playerCommands.SendNewPassword( new SendNewPasswordData { NewPassword = "******", PlayerId = Guid.NewGuid(), SendBy = SendBy.Email })); Assert.IsNotEmpty(e.Message); }
public void Password_length_validation_works(string password) { _playerCommands = Container.Resolve <PlayerCommands>(); var p = FakePlayerRepository.Players.FirstOrDefault(); Assert.That(p, Is.Not.Null); var e = Assert.Throws <RegoValidationException>( () => _playerCommands.SendNewPassword( new SendNewPasswordData { NewPassword = password, PlayerId = p.Id, SendBy = SendBy.Email })); Assert.IsNotEmpty(e.Message); }
public void Correct_Call_NotificationService(SendBy sendBy) { var busMock = new Mock <IServiceBus>(); Container.RegisterInstance <IServiceBus>(busMock.Object); _playerCommands = Container.Resolve <PlayerCommands>(); var player = FakePlayerRepository.Players.FirstOrDefault(); Assert.That(player, Is.Not.Null); const string newPassword = "******"; _playerCommands.SendNewPassword(new SendNewPasswordData { NewPassword = newPassword, PlayerId = player.Id, SendBy = sendBy }); if (sendBy == SendBy.Email) { busMock.Verify( n => n.PublishMessage( It.IsAny <EmailCommandMessage>()), Times.Once); busMock.Verify( n => n.PublishMessage( It.IsAny <SmsCommandMessage>()), Times.Never); } else { busMock.Verify( n => n.PublishMessage( It.IsAny <SmsCommandMessage>()), Times.Once); busMock.Verify(n => n.PublishMessage( It.IsAny <EmailCommandMessage>()), Times.Never); } }