Exemple #1
0
        public Task TestLink()
        {
            IObjectState state = new MutableObjectState
            {
                ObjectId   = "some0neTol4v4",
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            IObjectState newState = new MutableObjectState
            {
                ServerData = new Dictionary <string, object>()
                {
                    { "garden", "ofWords" }
                }
            };
            ParseUser user = ParseObjectExtensions.FromState <ParseUser>(state, "_User");
            var       mockObjectController = new Mock <IParseObjectController>();

            mockObjectController.Setup(obj => obj.SaveAsync(It.IsAny <IObjectState>(),
                                                            It.IsAny <IDictionary <string, IParseFieldOperation> >(),
                                                            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>();

            return(user.LinkWithAsync("parse", new Dictionary <string, object>(), CancellationToken.None).ContinueWith(t =>
            {
                Assert.IsFalse(t.IsFaulted);
                Assert.IsFalse(t.IsCanceled);
                mockObjectController.Verify(obj => obj.SaveAsync(It.IsAny <IObjectState>(),
                                                                 It.IsAny <IDictionary <string, IParseFieldOperation> >(),
                                                                 It.IsAny <string>(),
                                                                 It.IsAny <CancellationToken>()), Times.Exactly(1));
                Assert.IsFalse(user.IsDirty);
                Assert.IsNotNull(user.GetAuthData());
                Assert.IsNotNull(user.GetAuthData()["parse"]);
                Assert.AreEqual("some0neTol4v4", user.ObjectId);
                Assert.AreEqual("ofWords", user["garden"]);
            }));
        }
 public static Task LinkWithAsync(this ParseUser user, string authType, IDictionary <string, object> data,
                                  CancellationToken cancellationToken)
 {
     return(user.LinkWithAsync(authType, data, cancellationToken));
 }
 public static Task LinkWithAsync(this ParseUser user, string authType, CancellationToken cancellationToken)
 {
     return(user.LinkWithAsync(authType, cancellationToken));
 }