public void TestAllCultures() { KiiUser user = KiiUser.BuilderWithEmail(CurrentTimeMillis() + "@kii.com").Build(); user.Register("password"); foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { user.Locale = new LocaleContainer(cultureInfo); user.Update(); KiiUser actual = KiiUser.UserWithID(user.ID); actual.Refresh(); Assert.AreEqual(cultureInfo, actual.Locale.CultureInfo, cultureInfo.ToString()); } foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { if (cultureInfo.IsNeutralCulture) { user.Locale = new LocaleContainer(cultureInfo); user.Update(); KiiUser actual = KiiUser.UserWithID(user.ID); actual.Refresh(); String expected = cultureInfo.Name.ToLower(); if (expected == "zh-chs") { expected = "zh-cn"; } else if (expected == "zh-cht") { expected = "zh-hk"; } Assert.AreEqual(expected, actual.Locale.LocaleString, cultureInfo.Name); } } }
public void Test_0110_Update_other_user() { this.LogIn(); KiiUser user = KiiUser.CreateByUri(new Uri("kiicloud://users/1234")); user["age"] = 29; // set response client.AddResponse(200, "{" + "\"modifiedAt\" : 1386684079176" + "}"); bool done = false; KiiUser updated = null; Exception exception = null; user.Update((KiiUser u, Exception e) => { done = true; updated = u; exception = e; }); Assert.IsTrue(done); Assert.IsNull(updated); Assert.IsNotNull(exception); Assert.IsTrue(exception is InvalidOperationException); }
public void Test_0111_Update_Server_error() { this.LogIn(); KiiUser user = KiiUser.CurrentUser; user["age"] = 29; // set response client.AddResponse(new CloudException(400, "{}")); bool done = false; KiiUser updated = null; Exception exception = null; user.Update((KiiUser u, Exception e) => { done = true; updated = u; exception = e; }); Assert.IsTrue(done); Assert.IsNull(updated); Assert.IsNotNull(exception); Assert.IsTrue(exception is CloudException); }
public void UpdateWithExistingPhoneTest_Async() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; KiiUser newUser = KiiUser.BuilderWithName(username).Build(); newUser.Register("123ABC"); CountDownLatch cd = new CountDownLatch(1); Exception e = null; IdentityData.Builder builder = IdentityData.Builder.CreateWithPhone(this.existingUser.Phone); IdentityData identityData = builder.Build(); newUser.Update(identityData, null, (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); }
public void Test_0100_Update() { this.LogIn(); KiiUser user = KiiUser.CurrentUser; user["age"] = 29; // set response client.AddResponse(200, "{" + "\"modifiedAt\" : 1386684079176" + "}"); bool done = false; KiiUser updated = null; Exception exception = null; user.Update((KiiUser u, Exception e) => { done = true; updated = u; exception = e; }); Assert.IsTrue(done); Assert.IsNotNull(updated); Assert.IsNull(exception); // Assertion Assert.AreEqual(29, updated["age"]); }
public void UpdateByUnnoticedNormalUserTest_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 user = KiiUser.BuilderWithName(username).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(); KiiUser updatedUser = null; unnoticedNormalUser.Update(identityData, null, (KiiUser u, Exception e2) => { updatedUser = u; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 10))) { Assert.Fail("Callback not fired."); } Assert.AreEqual(email, updatedUser.Email); Assert.AreEqual(phone, updatedUser.Phone); }
public void UpdateTest() { string unixTime = CurrentTimeMillis().ToString(); string username = "******" + unixTime; string email = username + "@kii.com"; string phone = "+874" + unixTime.Substring(unixTime.Length - 9, 9); KiiUser newUser = KiiUser.BuilderWithName(username).Build(); newUser["birthday"] = "1978/7/22"; newUser.Register("123ABC"); IdentityData.Builder builder = IdentityData.Builder.CreateWithEmail(email); builder.WithPhone(phone); IdentityData identityData = builder.Build(); UserFields userFields = new UserFields(); userFields.Displayname = "disp"; userFields.Country = "JP"; userFields["age"] = 30; userFields.RemoveFromServer("birthday"); newUser.Update(identityData, userFields); Assert.IsFalse(newUser.IsPseudoUser); Assert.AreEqual(username, newUser.Username); Assert.AreEqual(email, newUser.Email); Assert.AreEqual(phone, newUser.Phone); Assert.AreEqual("disp", newUser.Displayname); Assert.AreEqual("JP", newUser.Country); Assert.IsFalse(newUser.Has("birthday")); Assert.AreEqual(30, newUser.GetInt("age")); }
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); }
public void Test_0111_Update_Server_error() { this.LogIn(); KiiUser user = KiiUser.CurrentUser; user["age"] = 29; // set response client.AddResponse(new CloudException(400, "{}")); user.Update(); }
public void Test_0110_Update_other_user() { this.LogIn(); KiiUser user = KiiUser.CreateByUri(new Uri("kiicloud://users/1234")); user["age"] = 29; // set response client.AddResponse(200, "{" + "\"modifiedAt\" : 1386684079176" + "}"); user.Update(); }
public void Test_0100_Update() { this.LogIn(); KiiUser user = KiiUser.CurrentUser; user["age"] = 29; // set response client.AddResponse(200, "{" + "\"modifiedAt\" : 1386684079176" + "}"); user.Update(); // Assertion Assert.AreEqual(29, user["age"]); }
public void UpdateByUnnoticedNormalUserTest() { 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).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.Update(identityData, null); Assert.AreEqual(email, unnoticedNormalUser.Email); Assert.AreEqual(phone, unnoticedNormalUser.Phone); }