void tst_ServerWorkerTests::login(QString name, QString pass)
{
    LoginRequest loginRequest;
    loginRequest.set_name(name);
    loginRequest.set_password(pass);

    mc->addMessage( &loginRequest );
    QByteArray ba = mc->toArray();
    worker->readyRead(ba);
    mc->Clear();
}
void tst_ServerWorkerTests::loginChangesUserStatus()
{
    LoginRequest loginRequest;
    LoginRequestResponse loginResponse;

    loginRequest.set_name(QStringLiteral("testuser"));
    loginRequest.set_password(QStringLiteral("some_password"));

    mc->addMessage( &loginRequest );

    QByteArray ba = mc->toArray();
    worker->readyRead(ba);

    mc->Clear();
    QVERIFY(mc->fromArray(binaryMessage));
    QVERIFY(loginResponse.fromArray(mc->getCapsule(0).getData()));
    QVERIFY(loginResponse.replay() == protbuf::Replay::UserAlreadyLogged);
}
void tst_ServerWorkerTests::loginToServerBadUser()
{
    LoginRequest loginRequest;
    LoginRequestResponse loginResponse;

    loginRequest.set_name(QStringLiteral("bad_user"));
    loginRequest.set_password(QStringLiteral("bad_passwd"));

    mc->addMessage( &loginRequest );

    QByteArray ba = mc->toArray();
    worker->readyRead(ba);

    mc->Clear();
    QVERIFY(mc->fromArray(binaryMessage));
    QVERIFY(loginResponse.fromArray(mc->getCapsule(0).getData()));
    QVERIFY(loginResponse.replay() == protbuf::Replay::LoginDeny);
}