/// <summary> /// オブジェクトの削除を行います。 /// </summary> public static IObservable <Unit> DeleteAsyncAsStream(this NCMBUser origin) { return(Observable.Create <Unit>(observer => { var gate = new object(); var isDisposed = false; origin.DeleteAsync(error => { lock (gate) { if (isDisposed) { return; } if (error == null) { observer.OnNext(Unit.Default); observer.OnCompleted(); } else { observer.OnError(error); } } }); return Disposable.Create(() => { lock (gate) { isDisposed = true; } }); })); }
public IEnumerator LogInWithAuthDataAsyncTwitterThenDeleteOtherUser() { // テストデータ作成 NCMBUser user = new NCMBUser(); user.AuthData = twitterParams.param; // authData登録 user.LogInWithAuthDataAsync((NCMBException e) => { Assert.Null(e); user = new NCMBUser(); user.ObjectId = "anotherObjectId"; user.DeleteAsync(); NCMBTestSettings.CallbackFlag = true; }); yield return(NCMBTestSettings.AwaitAsync()); user = NCMBUser.CurrentUser; Assert.AreEqual("dummyObjectId", user.ObjectId); // twitterパラメータ確認 Dictionary <string, object> authData = user.GetAuthDataForProvider("twitter"); Assert.AreEqual("twitterDummyId", authData ["id"]); Assert.AreEqual("twitterDummyScreenName", authData ["screen_name"]); Assert.AreEqual("twitterDummyConsumerKey", authData ["oauth_consumer_key"]); Assert.AreEqual("twitterDummyConsumerSecret", authData ["consumer_secret"]); Assert.AreEqual("twitterDummyAuthToken", authData ["oauth_token"]); Assert.AreEqual("twitterDummyAuthSecret", authData ["oauth_token_secret"]); // 登録成功の確認 Assert.NotNull(NCMBUser._getCurrentSessionToken()); Assert.True(user.IsLinkWith("twitter")); Assert.True(NCMBTestSettings.CallbackFlag); }
public IEnumerator LogInWithAuthDataAsyncFacebookThenDeleteOtherUser() { // テストデータ作成 NCMBUser user = new NCMBUser(); user.AuthData = facebookParams.param; // authData登録 user.LogInWithAuthDataAsync((NCMBException e) => { Assert.Null(e); user = new NCMBUser(); user.ObjectId = "anotherObjectId"; user.DeleteAsync((NCMBException e1) => { Assert.Null(e1); NCMBTestSettings.CallbackFlag = true; }); }); yield return(NCMBTestSettings.AwaitAsync()); user = NCMBUser.CurrentUser; Assert.AreEqual("dummyObjectId", user.ObjectId); // facebookパラメータ確認 Dictionary <string, object> authData = user.GetAuthDataForProvider("facebook"); Assert.AreEqual("facebookDummyId", authData ["id"]); Assert.AreEqual("facebookDummyAccessToken", authData ["access_token"]); Assert.AreEqual("2017-02-07T01:02:03.004Z", authData ["expiration_date"]); // 登録成功の確認 Assert.IsNotEmpty(NCMBUser._getCurrentSessionToken()); Assert.True(user.IsLinkWith("facebook")); Assert.True(NCMBTestSettings.CallbackFlag); }
public IEnumerator LoginLogoutDeleteUser() { // テストデータ作成 NCMBUser.LogInAsync("tarou", "tarou", (e1) => { Assert.Null(e1); NCMBTestSettings.CallbackFlag = true; NCMBUser.LogOutAsync(); NCMBUser.LogInAsync("tarou", "tarou", (e2) => { Assert.Null(e2); NCMBUser user = new NCMBUser(); user.ObjectId = "anotherObjectId"; user.DeleteAsync((NCMBException e3) => { Assert.Null(e3); NCMBTestSettings.CallbackFlag = true; }); }); }); yield return(NCMBTestSettings.AwaitAsync()); Assert.True(NCMBTestSettings.CallbackFlag); Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken()); Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName); }
/// <summary> /// オブジェクトの削除を行います。 /// </summary> public static Task <bool> DeleteTaskAsync(this NCMBUser user) { var tcs = new TaskCompletionSource <bool>(); user.DeleteAsync(error => { if (error != null) { tcs.SetException(error); } else { tcs.SetResult(true); } }); return(tcs.Task); }
public IEnumerator DeleteOtherUserAfterLogin() { // テストデータ作成 NCMBUser.LogInAsync("tarou", "tarou", (e) => { Assert.Null(e); NCMBUser user = new NCMBUser(); user.ObjectId = "anotherObjectId"; user.DeleteAsync((NCMBException ex) => { Assert.Null(ex); NCMBTestSettings.CallbackFlag = true; }); }); yield return(NCMBTestSettings.AwaitAsync()); Assert.IsNotNull(NCMBUser.CurrentUser); Assert.AreEqual("tarou", NCMBUser.CurrentUser.UserName); Assert.AreEqual("dummySessionToken", NCMBUser._getCurrentSessionToken()); }
public void AddRoleUserTest() { // ユーザー作成 NCMBUser expertUser = new NCMBUser(); expertUser.UserName = "******"; expertUser.Password = "******"; expertUser.SignUpAsync((error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } }); NCMBTestSettings.AwaitAsync(); Assert.NotNull(expertUser.ObjectId); // ロール作成 NCMBRole expertPlanRole = new NCMBRole("expertPlan"); expertPlanRole.SaveAsync((error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } }); NCMBTestSettings.AwaitAsync(); Assert.NotNull(expertPlanRole.ObjectId); // 空のロールを検索 NCMBRole expertPlan = null; NCMBRole.GetQuery().WhereEqualTo("roleName", "expertPlan").FindAsync((roleList, error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } else { expertPlan = roleList.FirstOrDefault(); } }); NCMBTestSettings.AwaitAsync(); Assert.NotNull(expertPlan.ObjectId); // 空のロールにユーザーを追加 expertPlan.Users.Add(expertUser); expertPlan.SaveAsync((error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } }); NCMBTestSettings.AwaitAsync(); // ロールを検索 expertPlan = null; NCMBRole.GetQuery().WhereEqualTo("roleName", "expertPlan").FindAsync((roleList, error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } else { expertPlan = roleList.FirstOrDefault(); } }); NCMBTestSettings.AwaitAsync(); // ロールに所属するユーザーを検索 expertPlan.Users.GetQuery().FindAsync((userList, error) => { if (error != null) { Assert.Fail(error.ErrorMessage); } else { Assert.AreEqual(expertUser.ObjectId, userList.FirstOrDefault().ObjectId); NCMBTestSettings.CallbackFlag = true; // テストデータ削除 expertPlan.DeleteAsync(); expertUser.DeleteAsync(); } }); NCMBTestSettings.AwaitAsync(); Assert.True(NCMBTestSettings.CallbackFlag); }