Ejemplo n.º 1
0
        public Task TestUpgradeToRevocableSession()
        {
            IObjectState state = new MutableObjectState {
                ServerData = new Dictionary <string, object>()
                {
                    { "sessionToken", "llaKcolnu" }
                }
            };
            var mockController = new Mock <IParseSessionController>();

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

            var mockCurrentUserController = new Mock <IParseCurrentUserController>();

            ParseCorePlugins.Instance.SessionController     = mockController.Object;
            ParseCorePlugins.Instance.CurrentUserController = mockCurrentUserController.Object;

            CancellationTokenSource source = new CancellationTokenSource();

            return(ParseSession.UpgradeToRevocableSessionAsync("someSession", source.Token).ContinueWith(t => {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                mockController.Verify(obj => obj.UpgradeToRevocableSessionAsync(It.Is <string>(sessionToken => sessionToken == "someSession"),
                                                                                source.Token), Times.Exactly(1));

                Assert.AreEqual("llaKcolnu", t.Result);
            }));
        }
 public static Task <string> UpgradeToRevocableSessionAsync(string sessionToken, CancellationToken cancellationToken)
 {
     return(ParseSession.UpgradeToRevocableSessionAsync(sessionToken, cancellationToken));
 }