public async Task <IActionResult> Auth(UsrAdmin user) { UsrDataShell result = await _userAuthentication.AuthenticationAsync(user); if (result.Error == null) { return(Ok(result.UsrData_)); } SetErrorHeaders(result); return(BadRequest()); }
public void AuthenticationAsync_invalidLogin() { DataShell resultHashPassword = new DataShell(); mockDbOperations .Setup(m => m.GetUserHashPasswordAsync(user.Login)) .Returns(Task.FromResult(resultHashPassword)); var service = new UserAuthentication(mockDbOperations.Object, supportingMethods); var result = service.AuthenticationAsync(user).Result; Assert.Null(result.datas); Assert.NotNull(result.error); Assert.Null(result.data); Assert.Null(result.stringData); Assert.Equal("User not found", result.error); }
public void AuthenticationAsync_valid() { DataShell resultHashPassword = new DataShell { stringData = hashPassword }; mockDbOperations .Setup(m => m.GetUserHashPasswordAsync(It.IsAny <string>())) .Returns(Task.FromResult(resultHashPassword)); var service = new UserAuthentication(mockDbOperations.Object, supportingMethods); var result = service.AuthenticationAsync(user).Result; Assert.Null(result.datas); Assert.Null(result.error); Assert.Null(result.data); Assert.Null(result.stringData); }