public void ConfirmUserEmailChangeCommandHandler_Fails_For_Nonexistent_User() { var handler = new ConfirmUserEmailChangeCommandHandler(_repository); var command = new ConfirmUserEmailChangeCommand("*****@*****.**", "999999"); var result = handler.Execute(command); result.Errors.Should().HaveCount(1); result.Errors[0].Expression.ToString().Should().Be("c => c.ConfirmationCode"); result.Errors[0].Message.Should().Be("This confirmation code is invalid"); }
public void ConfirmUserEmailChangeCommandHandler_Succeeds() { var handler = new ConfirmUserEmailChangeCommandHandler(_repository); var command = new ConfirmUserEmailChangeCommand("*****@*****.**", "999999"); var user = Substitute.For <User>(); user.Email.Returns("*****@*****.**"); user.NewEmailConfirmationCode.Returns(999999); user.Status.Returns(UserStatus.Active); _context.Users.Add(user); var result = handler.Execute(command); result.Errors.Should().BeEmpty(); user.Received().ChangeEmail(); user.DidNotReceive().ChangeEmailFailed(); }
public void ConfirmUserEmailChangeCommandHandler_Fails_For_Wrong_Code() { var handler = new ConfirmUserEmailChangeCommandHandler(_repository); var command = new ConfirmUserEmailChangeCommand("*****@*****.**", "999999"); var user = Substitute.For <User>(); user.Email.Returns("*****@*****.**"); user.NewEmailConfirmationCode.Returns(555555); user.Status.Returns(UserStatus.Active); _context.Users.Add(user); var result = handler.Execute(command); result.Errors.Should().HaveCount(1); result.Errors[0].Expression.ToString().Should().Be("c => c.ConfirmationCode"); result.Errors[0].Message.Should().Be("This confirmation code is invalid"); user.DidNotReceive().ChangeEmail(); user.Received().ChangeEmailFailed(); }