public void LogInUserCommandHandler_Fails_For_Nonexistent_User() { var handler = new LogInUserCommandHandler(_repository); var command = new LogInUserCommand("*****@*****.**", "test"); var result = handler.Execute(command); result.Errors.Should().HaveCount(1); result.Errors[0].Expression.Should().BeNull(); result.Errors[0].Message.Should().Be("Invalid email or password"); }
public void LogInUserCommandHandler_Succeeds() { var handler = new LogInUserCommandHandler(_repository); var command = new LogInUserCommand("*****@*****.**", "test"); var user = Substitute.For <User>(); user.Email.Returns("*****@*****.**"); user.Password.Returns(new Password("test")); user.Status.Returns(UserStatus.Active); _context.Users.Add(user); var result = handler.Execute(command); result.Success.Should().BeTrue(); user.Received().LogIn(); user.DidNotReceive().LogInFailed(); }
public void LogInUserCommandHandler_Fails_For_Invalid_Password() { var handler = new LogInUserCommandHandler(_repository); var command = new LogInUserCommand("*****@*****.**", "wrong"); var user = Substitute.For <User>(); user.Email.Returns("*****@*****.**"); user.Password.Returns(new Password("test")); user.Status.Returns(UserStatus.Active); _context.Users.Add(user); var result = handler.Execute(command); result.Errors.Should().HaveCount(1); result.Errors[0].Expression.Should().BeNull(); result.Errors[0].Message.Should().Be("Invalid email or password"); user.DidNotReceive().LogIn(); user.Received().LogInFailed(); }