public Task TestSignUp() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object> { ["sessionToken"] = "llaKcolnu", ["username"] = "******", ["password"] = "******" } }; IObjectState newState = new MutableObjectState { ObjectId = "some0neTol4v4" }; ParseUser user = ParseObjectExtensions.FromState <ParseUser>(state, "_User"); Mock <IParseUserController> mockController = new Mock <IParseUserController>(); mockController.Setup(obj => obj.SignUpAsync(It.IsAny <IObjectState>(), It.IsAny <IDictionary <string, IParseFieldOperation> >(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(newState)); ParseCorePlugins.Instance = new ParseCorePlugins { UserController = mockController.Object }; ParseObject.RegisterSubclass <ParseUser>(); ParseObject.RegisterSubclass <ParseSession>(); return(user.SignUpAsync().ContinueWith(t => { Assert.IsFalse(t.IsFaulted); Assert.IsFalse(t.IsCanceled); mockController.Verify(obj => obj.SignUpAsync(It.IsAny <IObjectState>(), It.IsAny <IDictionary <string, IParseFieldOperation> >(), It.IsAny <CancellationToken>()), Times.Exactly(1)); Assert.IsFalse(user.IsDirty); Assert.AreEqual("ihave", user.Username); Assert.IsFalse(user.GetState().ContainsKey("password")); Assert.AreEqual("some0neTol4v4", user.ObjectId); })); }
public void TestPasswordGetterSetter() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "username", "kevin" }, { "password", "hurrah" }, } }; ParseUser user = ParseObjectExtensions.FromState <ParseUser>(state, "_User"); Assert.AreEqual("hurrah", user.GetState()["password"]); user.Password = "******"; Assert.NotNull(user.GetCurrentOperations()["password"]); }
public Task TestUserFetch() { IObjectState state = new MutableObjectState { ObjectId = "some0neTol4v4", ServerData = new Dictionary <string, object>() { { "sessionToken", "llaKcolnu" }, { "username", "ihave" }, { "password", "adream" } } }; IObjectState newState = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "Alliance", "rekt" } } }; ParseUser user = ParseObjectExtensions.FromState <ParseUser>(state, "_User"); var mockObjectController = new Mock <IParseObjectController>(); mockObjectController.Setup(obj => obj.FetchAsync(It.IsAny <IObjectState>(), It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(newState)); ParseCorePlugins.Instance = new ParseCorePlugins { ObjectController = mockObjectController.Object, CurrentUserController = new Mock <IParseCurrentUserController>().Object }; ParseObject.RegisterSubclass <ParseUser>(); ParseObject.RegisterSubclass <ParseSession>(); user["Alliance"] = "rekt"; return(user.FetchAsync().ContinueWith(t => { Assert.IsFalse(t.IsFaulted); Assert.IsFalse(t.IsCanceled); mockObjectController.Verify(obj => obj.FetchAsync(It.IsAny <IObjectState>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Exactly(1)); Assert.IsTrue(user.IsDirty); Assert.AreEqual("ihave", user.Username); Assert.IsTrue(user.GetState().ContainsKey("password")); Assert.AreEqual("some0neTol4v4", user.ObjectId); Assert.AreEqual("rekt", user["Alliance"]); })); }