///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>creates a number or rows </summary> ////////////////////////////////////////////////////////////////////// [Test] public void DefaultHostInsertAndStay() { Tracing.TraceMsg("Entering DefaultHostInsertAndStay"); int iCount = 0; FeedQuery query = new FeedQuery(); Service service = new Service(); service.RequestFactory = this.factory; query.Uri = new Uri(this.defaultHost); AtomFeed returnFeed = service.Query(query); AtomEntry entry; iCount = returnFeed.Entries.Count; // now we have all we need. for (int i = 0; i < this.iIterations; i++) { Tracing.TraceMsg("DefaultHostInsertAndStay: inserting entry #: " + i); entry = ObjectModelHelper.CreateAtomEntry(i); entry = returnFeed.Insert(entry); } Tracing.TraceMsg("DefaultHostInsertAndStay: inserted lot's of entries"); // done doing the inserts... // now query the guy again. returnFeed = service.Query(query); Assert.AreEqual(iCount + this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); }
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><b>this is an html test text</b></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; } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>creates X rows and updates it</summary> ////////////////////////////////////////////////////////////////////// [Test] public void DefaultHostMassiveInsertAndUpdate() { Tracing.TraceMsg("Entering DefaultHostMassiveInsertAndUpdate"); int iCount = 0; FeedQuery query = new FeedQuery(); Service service = new Service(); service.RequestFactory = this.factory; query.Uri = new Uri(this.defaultHost); AtomFeed returnFeed = service.Query(query); AtomEntry entry; iCount = returnFeed.Entries.Count; // now we have all we need. int z = 0; for (int i = 0; i < this.iIterations; i++) { z++; if (z > 500) { z = 0; // do a requery every hundreth to see mem usage Tracing.TraceMsg("Query at point: " + i); returnFeed = service.Query(query); } Tracing.TraceMsg("Inserting entry: " + i); entry = ObjectModelHelper.CreateAtomEntry(i); entry = returnFeed.Insert(entry); entry.Content.Content = "Updated entry: " + Guid.NewGuid().ToString(); entry.Update(); } // now query the guy again. returnFeed = service.Query(query); Assert.AreEqual(iCount + this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); Tracing.TraceMsg("Exiting DefaultHostMassiveInsertAndUpdate"); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <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); } } } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>creates a number or rows and delets them again</summary> ////////////////////////////////////////////////////////////////////// [Test] public void DefaultHostMassiveInsertAndDelete() { Tracing.TraceMsg("Entering DefaultHostMassiveInsertAndDelete"); int iCount = 0; FeedQuery query = new FeedQuery(); Service service = new Service(); service.RequestFactory = this.factory; query.Uri = new Uri(this.defaultHost); AtomFeed returnFeed = service.Query(query); AtomEntry entry; iCount = returnFeed.Entries.Count; AtomEntryCollection newEntries = new AtomEntryCollection(null); // now we have all we need. for (int i = 0; i < this.iIterations; i++) { entry = ObjectModelHelper.CreateAtomEntry(i); entry = returnFeed.Insert(entry); newEntries.Add(entry); } Tracing.TraceMsg("DefaultHostMassiveInsert: inserted lot's of entries"); // done doing the inserts... // now query the guy again. returnFeed = service.Query(query); Assert.AreEqual(iCount + this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); // now udpate the 100 entries we have added for (int i = 0; i < this.iIterations; i++) { entry = newEntries[i]; entry.Title.Text = Guid.NewGuid().ToString(); entry.Update(); } Tracing.TraceMsg("DefaultHostMassiveInsert: updated lot's of entries"); returnFeed = service.Query(query); Assert.AreEqual(iCount + this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now"); // let's find them and delete them... for (int i = 0; i < this.iIterations; i++) { entry = newEntries[i]; foreach (AtomEntry feedEntry in returnFeed.Entries) { if (String.Compare(feedEntry.Title.Text, entry.Title.Text) == 0) { // got him Tracing.TraceMsg("trying to delete entry: " + feedEntry.Title.Text + " = " + entry.Title.Text); feedEntry.Delete(); break; } } } // and a last time returnFeed = service.Query(query); Assert.AreEqual(iCount, returnFeed.Entries.Count, "feed should have the same number again"); Tracing.TraceMsg("DefaultHostMassiveInsertAndDelete: deleted lot's of entries"); }
////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test</summary> ////////////////////////////////////////////////////////////////////// [Test] public void GoogleBaseAuthenticationTest() { Tracing.TraceMsg("Entering Base AuthenticationTest"); FeedQuery query = new FeedQuery(); Service service = new GBaseService(this.ApplicationName, this.gBaseKey); int iCount; if (this.gBaseURI != null) { if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } service.RequestFactory = this.factory; query.Uri = new Uri(this.gBaseURI); AtomFeed baseFeed = service.Query(query); // this should have a batch URI Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI"); ObjectModelHelper.DumpAtomObject(baseFeed, CreateDumpFileName("AuthenticationTest")); iCount = baseFeed.Entries.Count; String strTitle = "Dinner time" + Guid.NewGuid().ToString(); if (baseFeed != null && baseFeed.Entries.Count > 0) { // get the first entry AtomEntry entry = baseFeed.Entries[0]; entry = ObjectModelHelper.CreateGoogleBaseEntry(1); entry.Title.Text = strTitle; GBaseEntry newEntry = baseFeed.Insert(entry) as GBaseEntry; newEntry.PublishingPriority = new PublishingPriority("high"); GBaseEntry updatedEntry = newEntry.Update() as GBaseEntry; // publishing priority does not seem to be echoed back // Assert.IsTrue(updatedEntry.PublishingPriority.Value == "high"); iCount++; Tracing.TraceMsg("Created google base 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"); } baseFeed = service.Query(query); if (baseFeed != null && baseFeed.Entries.Count > 0) { // look for the one with dinner time... foreach (AtomEntry entry in baseFeed.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"); } } } baseFeed = service.Query(query); if (baseFeed != null && baseFeed.Entries.Count > 0) { // look for the one with dinner time... foreach (AtomEntry entry in baseFeed.Entries) { Tracing.TraceMsg("Entrie title: " + entry.Title.Text); if (String.Compare(entry.Title.Text, strTitle) == 0) { entry.Delete(); iCount--; Tracing.TraceMsg("deleted entry"); } } } baseFeed = service.Query(query); service.Credentials = null; } }