public void Then_A_ClientRequestedByEmail() { var requestedEmail = ClientFactory.GENERIC_CLIENT_EMAIL; var client = ClientFactory.BuildDefaultClient(); _clientsRepositoryMocked .Expects .One .Method(x => x.GetClientByEmail(requestedEmail)) .With(requestedEmail) .Will(Return.Value(Task.FromResult(client))); var clientResult = _sut.GetClientByEmail(requestedEmail).Result; Assert.IsNotNull(clientResult); Assert.AreEqual(requestedEmail, clientResult.Email); }
protected override bool IsAuthorized(HttpActionContext actionContext) { bool isAuthorized = false; if (IsValidContext(actionContext)) { string[] userCredentials = GetUserCredentials(actionContext); var userName = userCredentials[0]; var userPassword = userCredentials[1]; var clientUser = Task.Run(() => _companyClientsService.GetClientByEmail(userName)).Result; if (ValidPassword(userPassword, clientUser)) { actionContext.RequestContext.Principal = BuildPrincipalWithUserData(clientUser); isAuthorized = true; } } return(isAuthorized); }