public async Task Handle_ValidCredentials_ShouldSucceed() { _mockUserReposytory.Setup(repo => repo.CheckPassword(It.IsAny <User>(), It.IsAny <string>())).ReturnsAsync(true); var useCase = new LoginUserUseCase(_mockUserReposytory.Object, _mockJwtFactory.Object, _mockTokenFactory.Object); var responce = await useCase.Handle(new LoginRequest("username", "password", "127.0.0.1"), _mockOutputPort.Object); Assert.True(responce); }
public async Task Handle_IncompleteCredentials_ShouldFailed() { _mockUserReposytory.Setup(repo => repo.CheckPassword(It.IsAny <User>(), It.IsAny <string>())).ReturnsAsync(false); var useCase = new LoginUserUseCase(_mockUserReposytory.Object, _mockJwtFactory.Object, _mockTokenFactory.Object); var responce = await useCase.Handle(new LoginRequest("", "password", "127.0.0.1"), _mockOutputPort.Object); Assert.False(responce); _mockTokenFactory.Verify(factory => factory.GenerateToken(32), Times.Never); }
public async Task Handler_IncorrectPassword_ShouldFail() { _mockUserReposytory.Setup(repo => repo.CheckPassword(It.IsAny <User>(), It.IsAny <string>())).ReturnsAsync(false); var useCase = new LoginUserUseCase(_mockUserReposytory.Object, _mockJwtFactory.Object, _mockTokenFactory.Object); var result = await useCase.Handle(new LoginRequest("username", "wrongpassword", "127.0.01"), _mockOutputPort.Object); Assert.False(result); _mockTokenFactory.Verify(factory => factory.GenerateToken(32), Times.Never); }