Commit 27510794 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add more unittest and fix ::SendLaterInfo(const SendLaterInfo &)

parent bce1dcb5
......@@ -47,6 +47,8 @@ SendLaterInfo::SendLaterInfo(const SendLaterInfo &info)
mRecurrence = info.isRecurrence();
mSubject = info.subject();
mTo = info.to();
mDateTime = info.dateTime();
mLastDateTimeSend = info.lastDateTimeSend();
}
SendLaterInfo::~SendLaterInfo()
......
......@@ -61,4 +61,52 @@ void SendLaterInfoTest::shouldRestoreFromSettings()
}
void SendLaterInfoTest::shouldNotValidIfIdIsNotValid()
{
SendLater::SendLaterInfo info;
const QString to = QLatin1String("kde.org");
info.setTo(to);
info.setSubject(QLatin1String("Subject"));
info.setRecurrence(true);
info.setRecurrenceEachValue(5);
info.setRecurrenceUnit(SendLater::SendLaterInfo::Years);
const QDate date(2014,1,1);
info.setDateTime(QDateTime(date));
info.setLastDateTimeSend(QDateTime(date));
QVERIFY(!info.isValid());
}
void SendLaterInfoTest::shouldNotValidIfDateIsNotValid()
{
SendLater::SendLaterInfo info;
const QString to = QLatin1String("kde.org");
info.setTo(to);
info.setItemId(Akonadi::Item::Id(42));
info.setSubject(QLatin1String("Subject"));
info.setRecurrence(true);
info.setRecurrenceEachValue(5);
info.setRecurrenceUnit(SendLater::SendLaterInfo::Years);
const QDate date(2014,1,1);
info.setLastDateTimeSend(QDateTime(date));
QVERIFY(!info.isValid());
}
void SendLaterInfoTest::shouldCopyInfo()
{
SendLater::SendLaterInfo info;
const QString to = QLatin1String("kde.org");
info.setTo(to);
info.setItemId(Akonadi::Item::Id(42));
info.setSubject(QLatin1String("Subject"));
info.setRecurrence(true);
info.setRecurrenceEachValue(5);
info.setRecurrenceUnit(SendLater::SendLaterInfo::Years);
const QDate date(2014,1,1);
info.setDateTime(QDateTime(date));
info.setLastDateTimeSend(QDateTime(date));
SendLater::SendLaterInfo copyInfo(info);
QCOMPARE(info, copyInfo);
}
QTEST_KDEMAIN(SendLaterInfoTest, NoGUI)
......@@ -29,6 +29,9 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldRestoreFromSettings();
void shouldNotValidIfIdIsNotValid();
void shouldNotValidIfDateIsNotValid();
void shouldCopyInfo();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment