2013-07-03 06:26:19 +08:00
|
|
|
#include <QSignalSpy>
|
2013-07-02 12:45:04 +08:00
|
|
|
#include <QTest>
|
|
|
|
|
|
2013-07-03 06:26:19 +08:00
|
|
|
#include <qredis/request.h>
|
2013-07-02 12:45:04 +08:00
|
|
|
#include "testclient.h"
|
|
|
|
|
|
|
|
|
|
void TestClient::initTestCase()
|
|
|
|
|
{
|
2013-07-04 01:55:41 +08:00
|
|
|
qRegisterMetaType<QRedis::Request::ReplyType>("ReplyType");
|
|
|
|
|
|
2013-07-02 12:45:04 +08:00
|
|
|
client.connectToHost("localhost");
|
|
|
|
|
QVERIFY(client.waitForConnected());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestClient::cleanupTestCase()
|
|
|
|
|
{
|
|
|
|
|
client.disconnectFromHost();
|
2013-07-02 12:51:48 +08:00
|
|
|
|
|
|
|
|
if(client.isConnected())
|
|
|
|
|
QVERIFY(client.waitForDisconnected());
|
2013-07-02 12:45:04 +08:00
|
|
|
}
|
2013-07-03 06:26:19 +08:00
|
|
|
|
|
|
|
|
void TestClient::testPing()
|
|
|
|
|
{
|
|
|
|
|
QRedis::Request * request = client.sendCommand("PING");
|
2013-07-04 01:55:41 +08:00
|
|
|
QSignalSpy spy(request, SIGNAL(reply(ReplyType,QVariant)));
|
|
|
|
|
|
2013-07-03 06:26:19 +08:00
|
|
|
QVERIFY(request->waitForReply());
|
2013-07-04 01:55:41 +08:00
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
|
QCOMPARE(spy[0][1].toString(), QString("PONG"));
|
2013-07-03 06:26:19 +08:00
|
|
|
}
|