Unit test for new fields in serial key #4715

This commit is contained in:
Jerry (Xinyu Hou) 2015-11-12 10:08:55 -08:00
parent 55df81b1a6
commit 8c4ccdf148
1 changed files with 23 additions and 2 deletions

View File

@ -58,13 +58,32 @@ TEST(SubscriptionTests, parsePlainSerial_validSerial_validSubscriptionKey)
{ {
// valid until 2 March 2049 // valid until 2 March 2049
SubscriptionManager subscriptionManager; SubscriptionManager subscriptionManager;
String painText("{v1;trial;Bob;1;2147483647;2147483647}"); String painText("{v1;trial;Bob;1;a@a.a;mock company;2147483647;2147483647}");
SubscriptionKey key; SubscriptionKey key;
subscriptionManager.parsePlainSerial(painText, key); subscriptionManager.parsePlainSerial(painText, key);
EXPECT_EQ("trial", key.m_type); EXPECT_EQ("trial", key.m_type);
EXPECT_EQ("Bob", key.m_name); EXPECT_EQ("Bob", key.m_name);
EXPECT_EQ(1, key.m_userLimit); EXPECT_EQ(1, key.m_userLimit);
EXPECT_EQ("a@a.a", key.m_email);
EXPECT_EQ("mock company", key.m_company);
EXPECT_EQ(2147483647, key.m_warnTime);
EXPECT_EQ(2147483647, key.m_expireTime);
}
TEST(SubscriptionTests, parsePlainSerial_validSerialWithoutCompany_validSubscriptionKey)
{
// valid until 2 March 2049
SubscriptionManager subscriptionManager;
String painText("{v1;trial;Bob;1;a@a.a;;2147483647;2147483647}");
SubscriptionKey key;
subscriptionManager.parsePlainSerial(painText, key);
EXPECT_EQ("trial", key.m_type);
EXPECT_EQ("Bob", key.m_name);
EXPECT_EQ(1, key.m_userLimit);
EXPECT_EQ("a@a.a", key.m_email);
EXPECT_EQ("", key.m_company);
EXPECT_EQ(2147483647, key.m_warnTime); EXPECT_EQ(2147483647, key.m_warnTime);
EXPECT_EQ(2147483647, key.m_expireTime); EXPECT_EQ(2147483647, key.m_expireTime);
} }
@ -81,13 +100,15 @@ TEST(SubscriptionTests, parsePlainSerial_expiredTrialSerial_throwException)
TEST(SubscriptionTests, parsePlainSerial_expiredBasicSerial_validSubscriptionKey) TEST(SubscriptionTests, parsePlainSerial_expiredBasicSerial_validSubscriptionKey)
{ {
SubscriptionManager subscriptionManager; SubscriptionManager subscriptionManager;
String painText("{v1;basic;Bob;1;1398297600;1398384000}"); String painText("{v1;basic;Bob;1;a@a.a;mock company;1398297600;1398384000}");
SubscriptionKey key; SubscriptionKey key;
subscriptionManager.parsePlainSerial(painText, key); subscriptionManager.parsePlainSerial(painText, key);
EXPECT_EQ("basic", key.m_type); EXPECT_EQ("basic", key.m_type);
EXPECT_EQ("Bob", key.m_name); EXPECT_EQ("Bob", key.m_name);
EXPECT_EQ(1, key.m_userLimit); EXPECT_EQ(1, key.m_userLimit);
EXPECT_EQ("a@a.a", key.m_email);
EXPECT_EQ("mock company", key.m_company);
EXPECT_EQ(1398297600, key.m_warnTime); EXPECT_EQ(1398297600, key.m_warnTime);
EXPECT_EQ(1398384000, key.m_expireTime); EXPECT_EQ(1398384000, key.m_expireTime);
} }