Example #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            LoginButton.Text    = "Loading...";
            LoginButton.Enabled = false;

            InstapaperConnector ipc = new InstapaperConnector(new OAuthHelper(htmlshizzlebrowser));

            ipc.OnOAuthFail += delegate(String message)
            {
                MessageBox.Show(this, message, "Login error");
                LoginButton.Text    = "Login";
                LoginButton.Enabled = true;
                emailBox.Focus();
            };
            ipc.OnOAuthTokenReceived += delegate(OAuthTokenEventArgs args)
            {
                Console.WriteLine(args.OAuthToken);
                ConfigData cd = Config.GetData();
                cd.oauth_token        = args.OAuthToken;
                cd.oauth_token_secret = args.OAuthTokenSecret;
                Config.Write();
                //MessageBox.Show("Your Token has been created", "Success");
                this.DialogResult = DialogResult.OK;
                this.Close();
            };

            ipc.GetOAuthToken(emailBox.Text, passwordBox.Text);
            //ipc.VerifyCredentials();
        }
        public void GetBookmarkText()
        {
            Login l = new Login();
            WebBrowser wb = l.GetBrowserElement();
            wb.DocumentCompleted += delegate(Object sender, WebBrowserDocumentCompletedEventArgs args)
            {
                OAuthHelper h = new OAuthHelper(wb); // TODO: Passenden Wert initialisieren
                InstapaperConnector target = new InstapaperConnector(h); // TODO: Passenden Wert initialisieren
                Folder folder = new Folder(target);
                folder.Id = Folder.STARRED;
                folder.GetBookmarks(delegate(IAsyncResult result)
                {
                    folder.Bookmarks[0].GetText(delegate(IAsyncResult res)
                    {
                        Assert.IsTrue(folder.Bookmarks[0].HtmlText.Length > 0);
                    });

                });

            };
        }
        public void GetBookmarksTest()
        {
            Login l = new Login();
            WebBrowser wb = l.GetBrowserElement();
            wb.DocumentCompleted += delegate(Object sender, WebBrowserDocumentCompletedEventArgs args)
            {
                OAuthHelper h = new OAuthHelper(wb); // TODO: Passenden Wert initialisieren
                InstapaperConnector target = new InstapaperConnector(h); // TODO: Passenden Wert initialisieren
                Folder folder = new Folder(target);
                folder.Id = Folder.STARRED;
                folder.GetBookmarks(delegate(IAsyncResult result)
                {
                    // Should return an empty List in case of zero folders

                    if (folder.Bookmarks.Count > 0)
                        foreach (Bookmark b in folder.Bookmarks)
                            Assert.IsNotNull(b);
                });

            };
        }
 public void GetFolderListTest()
 {
     Login l = new Login();
     WebBrowser wb = l.GetBrowserElement();
     wb.DocumentCompleted += delegate (Object sender, WebBrowserDocumentCompletedEventArgs args){
         OAuthHelper h = new OAuthHelper(wb); // TODO: Passenden Wert initialisieren
         InstapaperConnector target = new InstapaperConnector(h); // TODO: Passenden Wert initialisieren
         User user = new User(target);
         target.GetFolderList(user, delegate(IAsyncResult result)
         {
             // Should return an empty List in case of zero folders
             Console.WriteLine(user.Folders);
             if (user.Folders.Capacity > 0)
                 foreach (Folder f in user.Folders)
                     Assert.IsNotNull(f);
         });
     };
 }