public Task TestUserSave() { 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" } } }; AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User"); var mockObjectController = new Mock <IAVObjectController>(); mockObjectController.Setup(obj => obj.SaveAsync(It.IsAny <IObjectState>(), It.IsAny <IDictionary <string, IAVFieldOperation> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(newState)); AVPlugins.Instance = new AVPlugins { ObjectController = mockObjectController.Object, CurrentUserController = new Mock <IAVCurrentUserController>().Object }; AVObject.RegisterSubclass <AVUser>(); AVObject.RegisterSubclass <AVSession>(); user["Alliance"] = "rekt"; return(user.SaveAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); mockObjectController.Verify(obj => obj.SaveAsync(It.IsAny <IObjectState>(), It.IsAny <IDictionary <string, IAVFieldOperation> >(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Exactly(1)); Assert.False(user.IsDirty); Assert.AreEqual("ihave", user.Username); Assert.False(user.GetState().ContainsKey("password")); Assert.AreEqual("some0neTol4v4", user.ObjectId); Assert.AreEqual("rekt", user["Alliance"]); })); }
public void TestPasswordGetterSetter() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "username", "kevin" }, { "password", "hurrah" }, } }; AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User"); Assert.AreEqual("hurrah", user.GetState()["password"]); user.Password = "******"; Assert.NotNull(user.GetCurrentOperations()["password"]); }
public Task TestSignUp() { var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); Assert.AreEqual(u, user.Username); Assert.False(user.GetState().ContainsKey("password")); Assert.IsNotNull(user.ObjectId); })); }