public void Test_0201_ChangePhone_already_exists()
        {
            this.LogIn();

            string newPhone = "+818011112222";

            // set Response
            client.AddResponse(new CloudException(409,
                                                  "{" +
                                                  "\"errorCode\" : \"USER_ALREADY_EXISTS\"," +
                                                  "\"message\" : \"User with phoneNumber +818011112222 already exists\"," +
                                                  "\"value\" : \"+818011112222\"," +
                                                  "\"field\" : \"phoneNumber\"," +
                                                  "\"suppressed\" : [ ]" +
                                                  "}"));

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangePhone(newPhone, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is CloudException);
        }
        public void Test_0211_ChangePhone_invalid_phone_number()
        {
            this.LogIn();

            string newPhone = "invalidPhoneNumber";

            // set Response
            client.AddResponse(204, "");

            KiiUser.ChangePhone(newPhone);
        }
        public void Test_0210_ChangePhone_null()
        {
            this.LogIn();

            string newPhone = null;

            // set Response
            client.AddResponse(204, "");

            KiiUser.ChangePhone(newPhone);
        }
        public void Test_0200_ChangePhone()
        {
            this.LogIn();

            string newPhone = "+818011112222";

            // set Response
            client.AddResponse(204, "");

            KiiUser.ChangePhone(newPhone);
        }
예제 #5
0
    void PerformChangePhone(string newPhone)
    {
        message       = "Changing phone...";
        ButtonEnabled = false;

        KiiUser.ChangePhone(newPhone, (Exception e) =>
        {
            ButtonEnabled = true;
            if (e != null)
            {
                message = "Failed to change phone " + e.ToString();
                return;
            }
            message = "Change phone succeeded";
        });
    }
        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_0201_ChangePhone_already_exists()
        {
            this.LogIn();

            string newPhone = "+818011112222";

            // set Response
            client.AddResponse(new CloudException(409,
                                                  "{" +
                                                  "\"errorCode\" : \"USER_ALREADY_EXISTS\"," +
                                                  "\"message\" : \"User with phoneNumber +818011112222 already exists\"," +
                                                  "\"value\" : \"+818011112222\"," +
                                                  "\"field\" : \"phoneNumber\"," +
                                                  "\"suppressed\" : [ ]" +
                                                  "}"));

            KiiUser.ChangePhone(newPhone);
        }
        public void Test_0200_ChangePhone()
        {
            this.LogIn();

            string newPhone = "+818011112222";

            // set Response
            client.AddResponse(204, "");

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangePhone(newPhone, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

            Assert.IsTrue(done);
            Assert.IsNull(exception);
        }
        public void Test_0211_ChangePhone_invalid_phone_number()
        {
            this.LogIn();

            string newPhone = "invalidPhoneNumber";

            // set Response
            client.AddResponse(204, "");

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangePhone(newPhone, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(exception);
            Assert.IsTrue(exception is ArgumentException);
        }