public void VerifyUserTest() { IUserDAO userDao = new IUserDAOImpl(); bool result = userDao.Verify(new Users("falcon", MD5Util.GetMD5("123456"))); Assert.AreEqual(true, result); }
public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer clientPeer) { Dictionary <byte, object> data = operationRequest.Parameters; string username = DictUtil.GetValue(data, (byte)ParameterCode.Username) as string; string password = DictUtil.GetValue(data, (byte)ParameterCode.Password) as string; IUserDAO dao = new IUserDAOImpl(); Users u = new Users(username, password); OperationResponse resp = new OperationResponse(operationRequest.OperationCode); resp.ReturnCode = (short)(dao.Verify(u) ? ReturnCode.LoginSuccess : ReturnCode.LoginFailed); if (resp.ReturnCode == (short)ReturnCode.LoginSuccess) { MyClientPeer peer = clientPeer as MyClientPeer; if (peer != null) { peer.username = username; } } clientPeer.SendOperationResponse(resp, sendParameters); }