Esempio n. 1
0
        public Task TestRevocableSession()
        {
            IObjectState state = new MutableObjectState
            {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            IObjectState newState = new MutableObjectState
            {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "r:llaKcolnu" }
                }
            };
            AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User");
            var    mockSessionController = new Mock <IAVSessionController>();

            mockSessionController.Setup(obj => obj.UpgradeToRevocableSessionAsync("llaKcolnu",
                                                                                  It.IsAny <CancellationToken>())).Returns(Task.FromResult(newState));
            AVPlugins.Instance = new AVPlugins
            {
                SessionController = mockSessionController.Object
            };
            AVObject.RegisterSubclass <AVUser>();
            AVObject.RegisterSubclass <AVSession>();

            return(user.UpgradeToRevocableSessionAsync(CancellationToken.None).ContinueWith(t =>
            {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                mockSessionController.Verify(obj => obj.UpgradeToRevocableSessionAsync("llaKcolnu",
                                                                                       It.IsAny <CancellationToken>()), Times.Exactly(1));
                Assert.AreEqual("r:llaKcolnu", user.SessionToken);
            }));
        }
Esempio n. 2
0
 public static Task UpgradeToRevocableSessionAsync(this AVUser user, CancellationToken cancellationToken)
 {
     return(user.UpgradeToRevocableSessionAsync(cancellationToken));
 }