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

            string newEmail = "*****@*****.**";

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

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangeEmail(newEmail, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

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

            string newEmail = "invalidEmailFormat";

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

            KiiUser.ChangeEmail(newEmail);
        }
        public void Test_0110_ChangeEmail_null()
        {
            this.LogIn();

            string newEmail = null;

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

            KiiUser.ChangeEmail(newEmail);
        }
        public void Test_0100_ChangeEmail()
        {
            this.LogIn();

            string newEmail = "*****@*****.**";

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

            KiiUser.ChangeEmail(newEmail);
        }
    void PerformChangeEmail(string newEmail)
    {
        message       = "Changing email...";
        ButtonEnabled = false;

        KiiUser.ChangeEmail(newEmail, (Exception e) =>
        {
            ButtonEnabled = true;
            if (e != null)
            {
                message = "Failed to change email " + e.ToString();
                return;
            }
            message = "Change email succeeded";
        });
    }
        public void EmailVerificationTest()
        {
            // Register user with email
            string  username = "******" + CurrentTimeMillis();
            string  email    = username + "@kii.com";
            KiiUser user     = KiiUser.BuilderWithEmail(email).SetName(username).Build();

            user.Register("password");
            Assert.AreEqual(email, user.Email);
            Assert.IsFalse(user.EmailVerified);
            Assert.IsNull(user.PendingEmail);

            // verify Email by admin
            verifyEmail(user.ID, user.Email);

            // Check the user
            user.Refresh();
            Assert.AreEqual(email, user.Email);
            Assert.IsTrue(user.EmailVerified);
            Assert.IsNull(user.PendingEmail);

            // Change Email
            string newEmail = "new_" + email;

            KiiUser.ChangeEmail(newEmail);

            Assert.AreEqual(email, KiiUser.CurrentUser.Email);
            Assert.IsTrue(KiiUser.CurrentUser.EmailVerified);
            Assert.IsNull(KiiUser.CurrentUser.PendingEmail);

            // Check the user
            user.Refresh();
            Assert.AreEqual(email, user.Email);
            Assert.IsTrue(user.EmailVerified);
            Assert.AreEqual(newEmail, user.PendingEmail);

            // verify Email by admin
            verifyEmail(user.ID, user.PendingEmail);

            // Check the user
            user.Refresh();
            Assert.AreEqual(newEmail, user.Email);
            Assert.IsTrue(user.EmailVerified);
            Assert.IsNull(user.PendingEmail);
        }
        public void Test_0101_ChangeEmail_already_exists()
        {
            this.LogIn();

            string newEmail = "*****@*****.**";

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

            KiiUser.ChangeEmail(newEmail);
        }
        public void Test_0100_ChangeEmail()
        {
            this.LogIn();

            string newEmail = "*****@*****.**";

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

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangeEmail(newEmail, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

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

            string newEmail = "invalidEmailFormat";

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

            bool      done      = false;
            Exception exception = null;

            KiiUser.ChangeEmail(newEmail, (Exception e) =>
            {
                done      = true;
                exception = e;
            });

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