public void Test_0201_BuilderWithPhone_invalid_phone() { try { KiiUser.BuilderWithPhone(null); Assert.Fail("Argument Exception must be thrown"); } catch (ArgumentException) { // OK } catch { Assert.Fail("Argument Exception must be thrown"); } }
public void PhoneVerificationTest() { // Register user with phone number string username = "******" + CurrentTimeMillis(); string phone = GenerateGlobalPhoneNumber(); KiiUser user = KiiUser.BuilderWithPhone(phone).SetName(username).Build(); user.Register("password"); Assert.AreEqual(phone, user.Phone); Assert.IsFalse(user.PhoneVerified); Assert.IsNull(user.PendingPhone); // verify Phone by admin verifyPhone(user.ID, user.Phone); // Check the user user.Refresh(); Assert.AreEqual(phone, user.Phone); Assert.IsTrue(user.PhoneVerified); Assert.IsNull(user.PendingPhone); // Change phone number string newPhone = GenerateGlobalPhoneNumber(); KiiUser.ChangePhone(newPhone); Assert.AreEqual(phone, KiiUser.CurrentUser.Phone); Assert.IsTrue(KiiUser.CurrentUser.PhoneVerified); Assert.IsNull(KiiUser.CurrentUser.PendingPhone); // Check the user user.Refresh(); Assert.AreEqual(phone, user.Phone); Assert.IsTrue(user.PhoneVerified); Assert.AreEqual(newPhone, user.PendingPhone); // verify Phone by admin verifyPhone(user.ID, user.PendingPhone); // Check the user user.Refresh(); Assert.AreEqual(newPhone, user.Phone); Assert.IsTrue(user.PhoneVerified); Assert.IsNull(user.PendingPhone); }
public void Test_0002_Register_With_LocalPhoneNumber() { string response1 = @" { ""userID"" : ""0398e67a-818d-47ee-83fb-3519a6197b81"", ""internalUserID"" : 148478248144076800, ""phoneNumber"": ""09011112222"", ""phoneNumberVerified"": true } "; client.AddResponse(200, response1); string response2 = @" { ""id"" : ""0398e67a-818d-47ee-83fb-3519a6197b81"", ""expires_in"" : 148478248144076800, ""access_token"" : ""abcdefghijklmeopqrstuvwxyz0123456789"" } "; client.AddResponse(200, response2); client.AddResponse(200, response1); KiiUser user = KiiUser.BuilderWithPhone("09011112222").Build(); user.Country = "JP"; bool done = false; KiiUser user2 = null; Exception exception = null; user.Register("pass1234", (KiiUser created, Exception e) => { done = true; user2 = created; exception = e; }); Assert.IsTrue(done); Assert.IsNotNull(user2); Assert.IsNull(exception); Assert.AreEqual("0398e67a-818d-47ee-83fb-3519a6197b81", user2.ID); Assert.AreEqual("09011112222", user2.Phone); }
public void Test_0014_Register_LocalPhoneNumber_without_country() { // set response this.setStandardResponse(); KiiUser user = KiiUser.BuilderWithPhone("09011112222").Build(); bool done = false; KiiUser user2 = null; Exception exception = null; user.Register("pass1234", (KiiUser created, Exception e) => { done = true; user2 = created; exception = e; }); Assert.IsTrue(done); Assert.IsNotNull(user2); Assert.IsNotNull(exception); Assert.IsTrue(exception is ArgumentException); }
public void Test_0200_BuilderWithPhone_OK() { KiiUser.Builder builder = KiiUser.BuilderWithPhone("+819011112222"); Assert.AreEqual("+819011112222", builder.Build().Phone); }