public Task TestUnlink() { IObjectState state = new MutableObjectState { ObjectId = "some0neTol4v4", ServerData = new Dictionary <string, object>() { { "sessionToken", "llaKcolnu" }, { "authData", new Dictionary <string, object> { { "parse", new Dictionary <string, object>() } } } } }; IObjectState newState = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "garden", "ofWords" } } }; 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)); var mockCurrentUserController = new Mock <IAVCurrentUserController>(); mockCurrentUserController.Setup(obj => obj.IsCurrent(user)).Returns(true); AVPlugins.Instance = new AVPlugins { ObjectController = mockObjectController.Object, CurrentUserController = mockCurrentUserController.Object, }; AVObject.RegisterSubclass <AVUser>(); AVObject.RegisterSubclass <AVSession>(); return(user.UnlinkFromAsync("parse", CancellationToken.None).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.NotNull(user.GetAuthData()); Assert.False(user.GetAuthData().ContainsKey("parse")); Assert.AreEqual("some0neTol4v4", user.ObjectId); Assert.AreEqual("ofWords", user["garden"]); })); }
public void TestAuthDataGetter() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "email", "*****@*****.**" }, { "authData", new Dictionary <string, object>() { { "facebook", new Dictionary <string, object>() { { "sessionToken", "none" } } } } } } }; AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User"); Assert.AreEqual(1, user.GetAuthData().Count); Assert.IsInstanceOf <IDictionary <string, object> >(user.GetAuthData()["facebook"]); }