Пример #1
0
        public void TestGetSessionToken()
        {
            IObjectState state = new MutableObjectState {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            AVSession session = AVObjectExtensions.FromState <AVSession>(state, "_Session");

            Assert.NotNull(session);
            Assert.AreEqual("llaKcolnu", session.SessionToken);
        }
Пример #2
0
        public Task TestGetCurrentSessionWithNoCurrentUser()
        {
            var mockController            = new Mock <IAVSessionController>();
            var mockCurrentUserController = new Mock <IAVCurrentUserController>();

            AVPlugins.Instance = new AVPlugins {
                SessionController     = mockController.Object,
                CurrentUserController = mockCurrentUserController.Object,
            };

            return(AVSession.GetCurrentSessionAsync().ContinueWith(t => {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                Assert.Null(t.Result);
            }));
        }
Пример #3
0
        public Task TestGetCurrentSession()
        {
            IObjectState sessionState = new MutableObjectState {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "newllaKcolnu" }
                }
            };
            var mockController = new Mock <IAVSessionController>();

            mockController.Setup(obj => obj.GetSessionAsync(It.IsAny <string>(),
                                                            It.IsAny <CancellationToken>())).Returns(Task.FromResult(sessionState));

            IObjectState userState = new MutableObjectState {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            AVUser user = AVObjectExtensions.FromState <AVUser>(userState, "_User");
            var    mockCurrentUserController = new Mock <IAVCurrentUserController>();

            mockCurrentUserController.Setup(obj => obj.GetAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(user));
            AVPlugins.Instance = new AVPlugins {
                SessionController     = mockController.Object,
                CurrentUserController = mockCurrentUserController.Object,
            };
            AVObject.RegisterSubclass <AVSession>();

            return(AVSession.GetCurrentSessionAsync().ContinueWith(t => {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                mockController.Verify(obj => obj.GetSessionAsync(It.Is <string>(sessionToken => sessionToken == "llaKcolnu"),
                                                                 It.IsAny <CancellationToken>()), Times.Exactly(1));

                var session = t.Result;
                Assert.AreEqual("newllaKcolnu", session.SessionToken);
            }));
        }
Пример #4
0
 public static Task RevokeAsync(string sessionToken, CancellationToken cancellationToken)
 {
     return(AVSession.RevokeAsync(sessionToken, cancellationToken));
 }
Пример #5
0
 public static Task <string> UpgradeToRevocableSessionAsync(string sessionToken, CancellationToken cancellationToken)
 {
     return(AVSession.UpgradeToRevocableSessionAsync(sessionToken, cancellationToken));
 }