public void WithEmailOverwriteTest()
        {
            IdentityData.Builder builder = IdentityData.Builder.CreateWithEmail("*****@*****.**");
            builder.WithEmail("*****@*****.**");
            IdentityData data = builder.Build();

            Assert.AreEqual("*****@*****.**", data.Email);
            Assert.IsNull(data.UserName);
            Assert.IsNull(data.Phone);
        }
        public void WithLocalPhoneOverwriteTest()
        {
            IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone("09011112222");
            builder.WithPhone("09033334444");
            IdentityData data = builder.Build();

            Assert.AreEqual("09033334444", data.Phone);
            Assert.IsNull(data.UserName);
            Assert.IsNull(data.Email);
        }
        public void WithGlobalPhoneTest()
        {
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName("test");
            builder.WithPhone("+819011112222");
            IdentityData data = builder.Build();

            Assert.AreEqual("+819011112222", data.Phone);
            Assert.AreEqual("test", data.UserName);
            Assert.IsNull(data.Email);
        }
        public void WithNameOverwriteTest()
        {
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName("test");
            builder.WithName("hoge");
            IdentityData data = builder.Build();

            Assert.AreEqual("hoge", data.UserName);
            Assert.IsNull(data.Email);
            Assert.IsNull(data.Phone);
        }
        public void AllFieldsTest()
        {
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName("test");
            builder.WithEmail("*****@*****.**");
            builder.WithPhone("+819011112222");
            IdentityData data = builder.Build();

            Assert.AreEqual("test", data.UserName);
            Assert.AreEqual("*****@*****.**", data.Email);
            Assert.AreEqual("+819011112222", data.Phone);
        }
Ejemplo n.º 6
0
        public void UpdateWithExistingPhoneTest()
        {
            string  unixTime = CurrentTimeMillis().ToString();
            string  username = "******" + unixTime;
            KiiUser newUser  = KiiUser.BuilderWithName(username).Build();

            newUser.Register("123ABC");

            IdentityData.Builder builder      = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone);
            IdentityData         identityData = builder.Build();

            newUser.Update(identityData, null);
        }
Ejemplo n.º 7
0
        public void PutIdentityWithRemoveFieldsTest_Async()
        {
            CountDownLatch cd = new CountDownLatch(1);

            string  unixTime = CurrentTimeMillis().ToString();
            string  username = "******" + unixTime;
            string  email    = username + "@kii.com";
            string  phone    = "+874" + unixTime.Substring(unixTime.Length - 9, 9);
            KiiUser actual   = null;

            UserFields userFields = new UserFields();

            userFields.Country     = "US";
            userFields.Displayname = "disp";
            userFields["birthday"] = "1978/7/22";
            userFields["age"]      = 30;

            KiiUser.RegisterAsPseudoUser(userFields, (KiiUser registeredUser, Exception e1) => {
                IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username);
                builder.WithEmail(email);
                builder.WithPhone(phone);
                IdentityData identityData = builder.Build();

                UserFields removeFields = new UserFields();
                removeFields.RemoveDisplayname(); // remove displayname only local.
                removeFields.RemoveFromServer("birthday");
                removeFields["newFields"] = "new!!";

                registeredUser.PutIdentity(identityData, removeFields, "123ABC", (KiiUser user, Exception e2) => {
                    actual = user;
                    cd.Signal();
                });
            });

            if (!cd.Wait(new TimeSpan(0, 0, 0, 10)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsFalse(actual.IsPseudoUser);
            Assert.AreEqual(username, actual.Username);
            Assert.AreEqual(email, actual.Email);
            Assert.AreEqual(phone, actual.Phone);
            Assert.AreEqual("disp", actual.Displayname);
            Assert.AreEqual("US", actual.Country);
            Assert.IsFalse(actual.Has("birthday"));
            Assert.AreEqual(30, actual.GetInt("age"));
        }
Ejemplo n.º 8
0
        public void PutIdentityByUnnoticedNormalUserTest()
        {
            string unixTime = CurrentTimeMillis().ToString();
            string username = "******" + unixTime;
            string email    = username + "@kii.com";
            string phone    = "+874" + unixTime.Substring(unixTime.Length - 9, 9);

            KiiUser user = KiiUser.BuilderWithName(username).WithEmail(email).WithPhone(phone).Build();

            user.Register("password");

            KiiUser unnoticedNormalUser = KiiUser.CreateByUri(user.Uri);

            IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username);
            builder.WithEmail(email);
            builder.WithPhone(phone);
            IdentityData identityData = builder.Build();

            unnoticedNormalUser.PutIdentity(identityData, null, "123ABC");
        }
Ejemplo n.º 9
0
        public void PutIdentityWithExistingPhoneTest_Async()
        {
            CountDownLatch cd = new CountDownLatch(1);
            Exception      e  = null;

            KiiUser.RegisterAsPseudoUser(null, (KiiUser registeredUser, Exception e1) => {
                IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone);
                IdentityData identityData    = builder.Build();
                registeredUser.PutIdentity(identityData, null, "123ABC", (KiiUser user, Exception e2) => {
                    e = e2;
                    cd.Signal();
                });
            });

            if (!cd.Wait(new TimeSpan(0, 0, 0, 10)))
            {
                Assert.Fail("Callback not fired.");
            }
            Assert.IsNotNull(e);
            Assert.IsInstanceOfType(typeof(ConflictException), e);
        }
Ejemplo n.º 10
0
        public void PutIdentityByDeletedUserTest()
        {
            string unixTime = CurrentTimeMillis().ToString();
            string username = "******" + unixTime;
            string email    = username + "@kii.com";
            string phone    = "+874" + unixTime.Substring(unixTime.Length - 9, 9);

            KiiUser.RegisterAsPseudoUser(null);
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username);
            builder.WithEmail(email);
            builder.WithPhone(phone);
            IdentityData identityData = builder.Build();

            string currentUserId          = Kii.CurrentUser.ID;
            string currentUserAccessToken = KiiUser.AccessToken;

            KiiUser.CurrentUser.Delete();
            Kii.CurrentUser = KiiUser.GetById(currentUserId);
            KiiCloudEngine.UpdateAccessToken(currentUserAccessToken);

            KiiUser.CurrentUser.PutIdentity(identityData, null, "123ABC");
        }
Ejemplo n.º 11
0
        public void PutIdentityTest()
        {
            string unixTime = CurrentTimeMillis().ToString();
            string username = "******" + unixTime;
            string email    = username + "@kii.com";
            string phone    = "+874" + unixTime.Substring(unixTime.Length - 9, 9);

            KiiUser.RegisterAsPseudoUser(null);
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username);
            builder.WithEmail(email);
            builder.WithPhone(phone);
            IdentityData identityData = builder.Build();

            KiiUser.CurrentUser.PutIdentity(identityData, null, "123ABC");

            Assert.IsFalse(KiiUser.CurrentUser.IsPseudoUser);
            Assert.AreEqual(username, KiiUser.CurrentUser.Username);
            Assert.AreEqual(email, KiiUser.CurrentUser.Email);
            Assert.AreEqual(phone, KiiUser.CurrentUser.Phone);
            Assert.IsNull(KiiUser.CurrentUser.Displayname);
            Assert.IsNull(KiiUser.CurrentUser.Country);
            Assert.IsFalse(KiiUser.CurrentUser.Has("age"));
        }
Ejemplo n.º 12
0
        public void PutIdentityWithRemoveFieldsTest()
        {
            string unixTime = CurrentTimeMillis().ToString();
            string username = "******" + unixTime;
            string email    = username + "@kii.com";
            string phone    = "+874" + unixTime.Substring(unixTime.Length - 9, 9);

            UserFields userFields = new UserFields();

            userFields.Country     = "US";
            userFields.Displayname = "disp";
            userFields["birthday"] = "1978/7/22";
            userFields["age"]      = 30;

            KiiUser.RegisterAsPseudoUser(userFields);
            IdentityData.Builder builder = IdentityData.Builder.CreateWithName(username);
            builder.WithEmail(email);
            builder.WithPhone(phone);
            IdentityData identityData = builder.Build();

            UserFields removeFields = new UserFields();

            removeFields.RemoveDisplayname(); // remove displayname only local.
            removeFields.RemoveFromServer("birthday");
            removeFields["newFields"] = "new!!";

            KiiUser.CurrentUser.PutIdentity(identityData, removeFields, "123ABC");

            Assert.IsFalse(KiiUser.CurrentUser.IsPseudoUser);
            Assert.AreEqual(username, KiiUser.CurrentUser.Username);
            Assert.AreEqual(email, KiiUser.CurrentUser.Email);
            Assert.AreEqual(phone, KiiUser.CurrentUser.Phone);
            Assert.AreEqual("disp", KiiUser.CurrentUser.Displayname);
            Assert.AreEqual("US", KiiUser.CurrentUser.Country);
            Assert.IsFalse(KiiUser.CurrentUser.Has("birthday"));
            Assert.AreEqual(30, KiiUser.CurrentUser.GetInt("age"));
        }
Ejemplo n.º 13
0
            /// <summary>
            /// Build IdentityData instance.
            /// </summary>
            /// <remarks>Build IdentityData instance with username, email and phone if they're set.</remarks>
            /// <returns>
            /// IdentityData instance.
            /// </returns>
            public IdentityData Build()
            {
                IdentityData identityData = new IdentityData(this.userName, this.email, this.phone);

                return(identityData);
            }