예제 #1
0
        private void AddEntry_Click(object sender, System.EventArgs e)
        {
            addentry dlg = new addentry();

            if (dlg.ShowDialog() == DialogResult.OK &&
                dlg.Entry.Length > 0)
            {
                // now add this to the feed.

                BloggerEntry entry = new BloggerEntry();

                entry.Content.Content = dlg.Entry;
                entry.Content.Type    = "html";
                entry.Title.Text      = dlg.EntryTitle;


                string userName = this.UserName.Text;
                string passWord = this.Password.Text;

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

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

                service.Insert(new Uri(this.feedUri), entry);

                RefreshFeed(this.feedUri);
            }
        }
예제 #2
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);
                    }
                }
            }
        }
예제 #3
0
        public void BloggerETagTest()
        {
            Tracing.TraceMsg("Entering BloggerETagTest");

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

            service.ProtocolMajor = 2;

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

            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;

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

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

            string etagOld = returnedEntry.Etag;

            returnedEntry.Content.Content = "This is a test";

            BloggerEntry newEntry = returnedEntry.Update() as BloggerEntry;

            Assert.IsTrue(newEntry.Etag != null);
            Assert.IsTrue(newEntry.Etag != etagOld);
        }