Exemple #1
0
        public Task TestBecome()
        {
            IObjectState state = new MutableObjectState
            {
                ObjectId   = "some0neTol4v4",
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            var mockController = new Mock <IAVUserController>();

            mockController.Setup(obj => obj.GetUserAsync("llaKcolnu",
                                                         It.IsAny <CancellationToken>())).Returns(Task.FromResult(state));
            AVPlugins.Instance = new AVPlugins
            {
                UserController = mockController.Object
            };
            AVObject.RegisterSubclass <AVUser>();
            AVObject.RegisterSubclass <AVSession>();

            return(AVUser.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);
            }));
        }