public void Test_CompleteResetPasswordWithoutIdentifier()
        {
            string newPassword = "******";
            string pinCode     = "1234";

            KiiUser.CompleteResetPassword(null, pinCode, newPassword);
        }
        public void Test_CompleteResetPasswordWithoutPinCode()
        {
            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";

            KiiUser.CompleteResetPassword(identifier, null, newPassword);
        }
        public void Test_CompleteResetPasswordWithEmail_Async()
        {
            CountDownLatch cd = new CountDownLatch(1);
            Exception      ex = null;

            string identifier  = "*****@*****.**";
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(204, null);
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword, (Exception e) => {
                ex = e;
                cd.Signal();
            });
            if (!cd.Wait(new TimeSpan(0, 0, 0, 3)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsNull(ex);

            Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod [0]);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/users/EMAIL:" + identifier + "/password/complete-reset", client.RequestUrl [0]);
            Assert.AreEqual(String.Format("{{\"newPassword\":\"{0}\",\"pinCode\":\"{1}\"}}", newPassword, pinCode), client.RequestBody[0]);
            Assert.AreEqual("application/vnd.kii.CompletePasswordResetRequest+json", client.RequestHeader[0]["content-type"]);
        }
        public void Test_CompleteResetPasswordError409()
        {
            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(new ConflictException("", null, "", ConflictException.Reason.INVALID_STATUS));
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword);
        }
        public void Test_CompleteResetPasswordError403()
        {
            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(new ForbiddenException("", null, ""));
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword);
        }
        public void Test_CompleteResetPasswordError400()
        {
            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(new BadRequestException("", null, "", BadRequestException.Reason.__UNKNOWN__));
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword);
        }
        public void Test_CompleteResetPasswordWithoutPassword()
        {
            string identifier = Guid.NewGuid().ToString();
            string pinCode    = "1234";

            client.AddResponse(204, null);
            KiiUser.CompleteResetPassword(identifier, pinCode, null);

            Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod [0]);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/users/" + identifier + "/password/complete-reset", client.RequestUrl [0]);
            Assert.AreEqual(String.Format("{{\"pinCode\":\"{0}\"}}", pinCode), client.RequestBody[0]);
            Assert.AreEqual("application/vnd.kii.CompletePasswordResetRequest+json", client.RequestHeader[0]["content-type"]);
        }
        public void Test_CompleteResetPasswordWithPhone()
        {
            string identifier  = "+818034068125";
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(204, null);
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword);

            Assert.AreEqual(KiiHttpMethod.POST, client.RequestMethod [0]);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/users/PHONE:" + identifier + "/password/complete-reset", client.RequestUrl [0]);
            Assert.AreEqual(String.Format("{{\"newPassword\":\"{0}\",\"pinCode\":\"{1}\"}}", newPassword, pinCode), client.RequestBody[0]);
            Assert.AreEqual("application/vnd.kii.CompletePasswordResetRequest+json", client.RequestHeader[0]["content-type"]);
        }
        public void Test_CompleteResetPasswordWithoutPinCode_Async()
        {
            CountDownLatch cd = new CountDownLatch(1);
            Exception      ex = null;

            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";

            KiiUser.CompleteResetPassword(identifier, null, newPassword, (Exception e) => {
                ex = e;
                cd.Signal();
            });
            if (!cd.Wait(new TimeSpan(0, 0, 0, 3)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsNotNull(ex);
            Assert.IsTrue(ex is ArgumentException);
        }
        public void Test_CompleteResetPasswordError409_Async()
        {
            CountDownLatch cd = new CountDownLatch(1);
            Exception      ex = null;

            string identifier  = Guid.NewGuid().ToString();
            string newPassword = "******";
            string pinCode     = "1234";

            client.AddResponse(new ConflictException("", null, "", ConflictException.Reason.INVALID_STATUS));
            KiiUser.CompleteResetPassword(identifier, pinCode, newPassword, (Exception e) => {
                ex = e;
                cd.Signal();
            });
            if (!cd.Wait(new TimeSpan(0, 0, 0, 3)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsNotNull(ex);
            Assert.IsTrue(ex is ConflictException);
        }
        public void Step02_ResetPasswordViaSmsPin()
        {
            KiiUser user = KiiUser.LogIn(this.realPhoneNumber, "password");

            KiiUser.CompleteResetPassword(user.ID, this.realPinCode, null);
        }