コード例 #1
0
        public Task TestUpgradeToRevocableSession()
        {
            Tuple <HttpStatusCode, IDictionary <string, object> > response = new Tuple <HttpStatusCode, IDictionary <string, object> >(HttpStatusCode.Accepted,
                                                                                                                                       new Dictionary <string, object>
            {
                ["__type"]       = "Object",
                ["className"]    = "Session",
                ["sessionToken"] = "S0m3Se551on",
                ["restricted"]   = true
            });

            Mock <IParseCommandRunner> mockRunner = CreateMockRunner(response);

            return(new ParseSessionController(mockRunner.Object, Client.Decoder).UpgradeToRevocableSessionAsync("S0m3Se551on", Client, CancellationToken.None).ContinueWith(task =>
            {
                Assert.IsFalse(task.IsFaulted);
                Assert.IsFalse(task.IsCanceled);
                mockRunner.Verify(obj => obj.RunCommandAsync(It.Is <ParseCommand>(command => command.Path == "upgradeToRevocableSession"), It.IsAny <IProgress <IDataTransferLevel> >(), It.IsAny <IProgress <IDataTransferLevel> >(), It.IsAny <CancellationToken>()), Times.Exactly(1));

                IObjectState session = task.Result;
                Assert.AreEqual(2, session.Count());
                Assert.IsTrue((bool)session["restricted"]);
                Assert.AreEqual("S0m3Se551on", session["sessionToken"]);
            }));
        }
コード例 #2
0
        public Task TestUpgradeToRevocableSession()
        {
            Tuple <HttpStatusCode, IDictionary <string, object> > response = new Tuple <HttpStatusCode, IDictionary <string, object> >(HttpStatusCode.Accepted,
                                                                                                                                       new Dictionary <string, object>()
            {
                { "__type", "Object" },
                { "className", "Session" },
                { "sessionToken", "S0m3Se551on" },
                { "restricted", true }
            });
            Mock <IParseCommandRunner> mockRunner = CreateMockRunner(response);

            ParseSessionController controller = new ParseSessionController(mockRunner.Object);

            return(controller.UpgradeToRevocableSessionAsync("S0m3Se551on", CancellationToken.None).ContinueWith(t =>
            {
                Assert.IsFalse(t.IsFaulted);
                Assert.IsFalse(t.IsCanceled);
                mockRunner.Verify(obj => obj.RunCommandAsync(It.Is <ParseCommand>(command => command.Uri.AbsolutePath == "/1/upgradeToRevocableSession"),
                                                             It.IsAny <IProgress <ParseUploadProgressEventArgs> >(),
                                                             It.IsAny <IProgress <ParseDownloadProgressEventArgs> >(),
                                                             It.IsAny <CancellationToken>()), Times.Exactly(1));

                IObjectState session = t.Result;
                Assert.AreEqual(2, session.Count());
                Assert.IsTrue((bool)session["restricted"]);
                Assert.AreEqual("S0m3Se551on", session["sessionToken"]);
            }));
        }