Beispiel #1
0
        public void BloggerVersion2Test()
        {
            Tracing.TraceMsg("Entering BloggerVersion2Test");

            BloggerQuery   query   = new BloggerQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            string title = "V1" + Guid.NewGuid().ToString();

            service.ProtocolMajor = 1;

            service.RequestFactory = this.factory;
            query.Uri = new Uri(this.bloggerURI);

            // insert a new entry in version 1

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Categories.Clear();
            entry.Title.Text    = title;
            entry.IsDraft       = true;
            entry.ProtocolMajor = 12;



            AtomEntry returnedEntry = service.Insert(new Uri(this.bloggerURI), entry);

            Assert.IsTrue(returnedEntry.ProtocolMajor == service.ProtocolMajor);
            Assert.IsTrue(entry.IsDraft);
            Assert.IsTrue(returnedEntry.IsDraft);

            BloggerFeed feed = service.Query(query);

            Assert.IsTrue(feed.ProtocolMajor == service.ProtocolMajor);
            if (feed != null)
            {
                Assert.IsTrue(feed.TotalResults >= feed.Entries.Count, "totalresults should be >= number of entries");
                Assert.IsTrue(feed.Entries.Count > 0, "We should have some entries");
            }

            service.ProtocolMajor = 2;
            feed = service.Query(query);
            Assert.IsTrue(feed.ProtocolMajor == service.ProtocolMajor);

            if (feed != null)
            {
                Assert.IsTrue(feed.Entries.Count > 0, "We should have some entries");
                Assert.IsTrue(feed.TotalResults >= feed.Entries.Count, "totalresults should be >= number of entries");

                foreach (BloggerEntry e in feed.Entries)
                {
                    if (e.Title.Text == title)
                    {
                        Assert.IsTrue(e.ProtocolMajor == 2);
                        Assert.IsTrue(e.IsDraft);
                    }
                }
            }
        }
Beispiel #2
0
        public void BloggerHTMLTest()
        {
            Tracing.TraceMsg("Entering BloggerHTMLTest");

            FeedQuery      query   = new FeedQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            if (this.bloggerURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.bloggerURI);
                AtomFeed feed = service.Query(query);

                String strTitle = "Dinner time" + Guid.NewGuid().ToString();

                if (feed != null)
                {
                    // get the first entry
                    String    htmlContent = "<div>&lt;b&gt;this is an html test text&lt;/b&gt;</div>";
                    AtomEntry entry       = ObjectModelHelper.CreateAtomEntry(1);
                    entry.Categories.Clear();
                    entry.Title.Text      = strTitle;
                    entry.Content.Type    = "html";
                    entry.Content.Content = htmlContent;

                    AtomEntry newEntry = feed.Insert(entry);
                    Tracing.TraceMsg("Created blogger entry");

                    // try to get just that guy.....
                    FeedQuery singleQuery = new FeedQuery();
                    singleQuery.Uri = new Uri(newEntry.SelfUri.ToString());
                    AtomFeed  newFeed = service.Query(singleQuery);
                    AtomEntry sameGuy = newFeed.Entries[0];

                    Assert.IsTrue(sameGuy.Title.Text.Equals(newEntry.Title.Text), "both titles should be identical");
                    Assert.IsTrue(sameGuy.Content.Type.Equals("html"));
                    String input  = HttpUtility.HtmlDecode(htmlContent);
                    String output = HttpUtility.HtmlDecode(sameGuy.Content.Content);
                    Assert.IsTrue(input.Equals(output), "The input string should be equal the output string");
                }

                service.Credentials = null;
            }
        }
Beispiel #3
0
        public void BloggerPublicFeedTest()
        {
            Tracing.TraceMsg("Entering BloggerPublicFeedTest");

            FeedQuery      query   = new FeedQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            String publicURI = (String)this.externalHosts[0];

            if (publicURI != null)
            {
                service.RequestFactory = this.factory;

                query.Uri = new Uri(publicURI);
                AtomFeed feed = service.Query(query);

                if (feed != null)
                {
                    // look for the one with dinner time...
                    foreach (AtomEntry entry in feed.Entries)
                    {
                        Assert.IsTrue(entry.ReadOnly, "The entry should be readonly");
                    }
                }
            }
        }
Beispiel #4
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void BloggerStressTest()
        {
            Tracing.TraceMsg("Entering Blogger GoogleStressTest");

            FeedQuery      query   = new FeedQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            if (this.bloggerURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.bloggerURI);
                AtomFeed blogFeed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(blogFeed, CreateDumpFileName("AuthenticationTest"));

                if (blogFeed != null)
                {
                    for (int i = 0; i < 30; i++)
                    {
                        AtomEntry entry = ObjectModelHelper.CreateAtomEntry(i);
                        entry.Categories.Clear();
                        entry.Title.Text      = "Title " + i;
                        entry.Content.Content = "Some text...";
                        entry.Content.Type    = "html";

                        blogFeed.Insert(entry);
                    }
                }
            }
        }
Beispiel #5
0
        private void RefreshFeed(string bloggerURI)
        {
            string userName = this.UserName.Text;
            string passWord = this.Password.Text;

            // Suppress repainting the TreeView until all the objects have been created.
            this.FeedView.BeginUpdate();
            // Clear the TreeView each time the method is called.
            this.FeedView.Nodes.Clear();

            if (this.feedUri != null)
            {
                BloggerQuery   query   = new BloggerQuery();
                BloggerService service = new BloggerService("BloggerSampleApp.NET");

                if (userName != null && userName.Length > 0)
                {
                    service.Credentials = new GDataCredentials(userName, passWord);
                }

                // only get event's for today - 1 month until today + 1 year

                query.Uri = new Uri(bloggerURI);

                // set wait cursor before...
                Cursor.Current = Cursors.WaitCursor;


                BloggerFeed bloggerFeed = service.Query(query);

                // Reset the cursor to the default for all controls.
                Cursor.Current = Cursors.Default;



                // now populate the calendar
                while (bloggerFeed != null && bloggerFeed.Entries.Count > 0)
                {
                    foreach (BloggerEntry entry in bloggerFeed.Entries)
                    {
                        int iIndex = this.FeedView.Nodes.Add(new TreeNode(entry.Title.Text));
                        if (iIndex >= 0)
                        {
                            AtomPerson author = entry.Authors[0];
                            this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode("by: " + author.Name));
                            this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode("published: " + entry.Published.ToString()));
                            if (entry.Content.Content.Length > 50)
                            {
                                this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(entry.Content.Content.Substring(0, 50) + "...."));
                            }
                            else
                            {
                                this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(entry.Content.Content));
                            }
                        }
                    }

                    // do the chunking...
                    if (bloggerFeed.NextChunk != null)
                    {
                        query.Uri   = new Uri(bloggerFeed.NextChunk);
                        bloggerFeed = service.Query(query);
                    }
                    else
                    {
                        bloggerFeed = null;
                    }
                }
            }

            // Reset the cursor to the default for all controls.
            Cursor.Current = Cursors.Default;
            // stop repainting the TreeView.
            this.FeedView.EndUpdate();
        }
Beispiel #6
0
        private void RefreshFeedList()
        {
            string bloggerURI = this.BloggerURI.Text;
            string userName   = this.UserName.Text;
            string passWord   = this.Password.Text;

            BloggerQuery   query   = new BloggerQuery();
            BloggerService service = new BloggerService("BloggerSampleApp.NET");

            if (userName != null && userName.Length > 0)
            {
                service.Credentials = new GDataCredentials(userName, passWord);
            }

            // only get event's for today - 1 month until today + 1 year

            query.Uri = new Uri(bloggerURI);

            Cursor.Current = Cursors.WaitCursor;

            // start repainting
            this.FeedChooser.BeginUpdate();

            BloggerFeed bloggerFeed = service.Query(query);

            // Display a wait cursor while the TreeNodes are being created.

            this.FeedChooser.DisplayMember = "Title";

            while (bloggerFeed != null && bloggerFeed.Entries.Count > 0)
            {
                foreach (BloggerEntry entry in bloggerFeed.Entries)
                {
                    int iIndex = this.FeedChooser.Items.Add(new ListEntry(entry));
                }
                // do the chunking...
                if (bloggerFeed.NextChunk != null)
                {
                    query.Uri   = new Uri(bloggerFeed.NextChunk);
                    bloggerFeed = service.Query(query);
                }
                else
                {
                    bloggerFeed = null;
                }
            }

            if (this.FeedChooser.Items.Count > 0)
            {
                this.FeedChooser.Items.Insert(0, "Choose the feed...");
            }
            else
            {
                this.FeedChooser.Items.Insert(0, "No feeds for this user...");
            }


            // Reset the cursor to the default for all controls.
            Cursor.Current = Cursors.Default;
            // End repainting the combobox
            this.FeedChooser.EndUpdate();
        }
Beispiel #7
0
        public void GoogleAuthenticationTest()
        {
            Tracing.TraceMsg("Entering Blogger AuthenticationTest");

            BloggerQuery   query   = new BloggerQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            int iCount;

            if (this.bloggerURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.bloggerURI);
                BloggerFeed blogFeed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(blogFeed, CreateDumpFileName("AuthenticationTest"));
                iCount = blogFeed.Entries.Count;

                String strTitle = "Dinner time" + Guid.NewGuid().ToString();

                if (blogFeed != null && blogFeed.Entries.Count > 0)
                {
                    BloggerEntry entry = ObjectModelHelper.CreateAtomEntry(1) as BloggerEntry;
                    // blogger does not like labels yet.
                    entry.Categories.Clear();
                    entry.Title.Text = strTitle;
                    entry.Categories.Clear();
                    entry.IsDraft   = true;
                    entry.Updated   = Utilities.EmptyDate;
                    entry.Published = Utilities.EmptyDate;
                    BloggerEntry newEntry = blogFeed.Insert(entry);
                    iCount++;
                    Tracing.TraceMsg("Created blogger entry");

                    // try to get just that guy.....
                    BloggerQuery singleQuery = new BloggerQuery();
                    singleQuery.Uri = new Uri(newEntry.SelfUri.ToString());

                    BloggerFeed newFeed = service.Query(singleQuery);

                    BloggerEntry sameGuy = newFeed.Entries[0] as BloggerEntry;

                    Tracing.TraceMsg("retrieved blogger entry");

                    Assert.IsTrue(sameGuy.Title.Text.Equals(newEntry.Title.Text), "both titles should be identical");
                    Assert.IsTrue(sameGuy.IsDraft);
                }

                blogFeed = service.Query(query);

                Assert.AreEqual(iCount, blogFeed.Entries.Count, "Feed should have one more entry, it has: " + blogFeed.Entries.Count);

                if (blogFeed != null && blogFeed.Entries.Count > 0)
                {
                    // look for the one with dinner time...
                    foreach (AtomEntry entry in blogFeed.Entries)
                    {
                        Tracing.TraceMsg("Entrie title: " + entry.Title.Text);
                        if (String.Compare(entry.Title.Text, strTitle) == 0)
                        {
                            entry.Content.Content = "Maybe stay until breakfast";
                            entry.Content.Type    = "text";
                            entry.Update();
                            Tracing.TraceMsg("Updated entry");
                        }
                    }
                }

                blogFeed = service.Query(query);

                Assert.AreEqual(iCount, blogFeed.Entries.Count, "Feed should have one more entry, it has: " + blogFeed.Entries.Count);

                if (blogFeed != null && blogFeed.Entries.Count > 0)
                {
                    // look for the one with dinner time...
                    foreach (AtomEntry entry in blogFeed.Entries)
                    {
                        Tracing.TraceMsg("Entrie title: " + entry.Title.Text);
                        if (String.Compare(entry.Title.Text, strTitle) == 0)
                        {
                            entry.Delete();
                            iCount--;
                            Tracing.TraceMsg("deleted entry");
                        }
                    }
                }


                blogFeed = service.Query(query);
                Assert.AreEqual(iCount, blogFeed.Entries.Count, "Feed should have the same count again, it has: " + blogFeed.Entries.Count);

                service.Credentials = null;
            }
        }