public Task TestBecome() { IObjectState state = new MutableObjectState { ObjectId = "some0neTol4v4", ServerData = new Dictionary <string, object>() { { "sessionToken", "llaKcolnu" } } }; var mockController = new Mock <IParseUserController>(); mockController.Setup(obj => obj.GetUserAsync("llaKcolnu", It.IsAny <CancellationToken>())).Returns(Task.FromResult(state)); ParseCorePlugins.Instance = new ParseCorePlugins { UserController = mockController.Object }; ParseObject.RegisterSubclass <ParseUser>(); ParseObject.RegisterSubclass <ParseSession>(); return(ParseUser.BecomeAsync("llaKcolnu").ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); mockController.Verify(obj => obj.GetUserAsync("llaKcolnu", It.IsAny <CancellationToken>()), Times.Exactly(1)); var user = t.Result; Assert.AreEqual("some0neTol4v4", user.ObjectId); Assert.AreEqual("llaKcolnu", user.SessionToken); })); }
public static async void SuccessFacebookLogin(string sessionToken, JObject obj) { var data = new UserPublicData() { firstName = obj["first_name"].ToString(), lastName = obj["last_name"].ToString(), gender = obj["gender"].ToString() }; await data.SaveAsync().ConfigureAwait(false); await ParseUser.BecomeAsync(sessionToken); (ParseUser.CurrentUser as UserModel).publicData = data; await ParseUser.CurrentUser.SaveAsync(); System.Diagnostics.Debug.WriteLine(ParseUser.CurrentUser.Username); }