Author: siwuzzz
Date: Wed May 30 15:51:41 2007
New Revision: 183

Modified:
   trunk/clients/cs/src/unittests/baselivetestclass.cs
   trunk/clients/cs/src/unittests/blogger.cs
   trunk/clients/cs/src/unittests/caltest.cs
   trunk/clients/cs/src/unittests/unittests.cs

Log:
unittests/baselivetestclass.cs:
- base class from which every tests running against live servers should run.
- handles SSL certificate validation failures
- now holds now the FeedCleanup() helper method (previously found in 
BaseTestClass)
- takes care for username/password storage/configuration
- added Category "LiveTests", which every live tests should have, to be run by 
the automated framework

unittests/unittests.cs:
- remove FeedCleanup() from BaseTestClass, moved it to BaseLiveTestClass.

unittests/blogger.cs:
- modified to comply with BaseLiveTestClass

unittests/caltest.cs:
- modified to comply with BaseLiveTestClass
- added a few tracing calls
- removed "GoogleCalendar" attribute

Modified: trunk/clients/cs/src/unittests/baselivetestclass.cs
==============================================================================
--- trunk/clients/cs/src/unittests/baselivetestclass.cs (original)
+++ trunk/clients/cs/src/unittests/baselivetestclass.cs Wed May 30 15:51:41 2007
@@ -17,6 +17,13 @@
        /// </summary>
        public class BaseLiveTestClass : BaseTestClass, ICertificatePolicy
        {
+        /// <summary>holds the username to use</summary>
+        protected string userName;
+        /// <summary>holds the password to use</summary>
+        protected string passWord;
+        /// <summary>holds the default authhandler</summary> 
+        protected string strAuthHandler;
+
         public BaseLiveTestClass()
         {
             ServicePointManager.CertificatePolicy = this;
@@ -26,5 +33,82 @@
         {
             return (true);
         }
+
+        protected override void ReadConfigFile()
+        {
+            base.ReadConfigFile();
+
+            if (unitTestConfiguration.Contains("authHandler") == true)
+            {
+                this.strAuthHandler = (string) 
unitTestConfiguration["authHandler"];
+                Tracing.TraceInfo("Read authHandler value: " + 
this.strAuthHandler);
+            }
+            if (unitTestConfiguration.Contains("userName") == true)
+            {
+                this.userName = (string) unitTestConfiguration["userName"];
+                Tracing.TraceInfo("Read userName value: " + this.userName);
+            }
+            if (unitTestConfiguration.Contains("passWord") == true)
+            {
+                this.passWord = (string) unitTestConfiguration["passWord"];
+                Tracing.TraceInfo("Read passWord value: " + this.passWord);
+            }
+        }
+
+        //////////////////////////////////////////////////////////////////////
+        /// <summary>empty a feed</summary> 
+        //////////////////////////////////////////////////////////////////////
+        protected void FeedCleanup(String uriToClean, String userName, String 
pwd)
+        {
+            Tracing.TraceCall();
+            Tracing.TraceCall("Cleaning URI: " + uriToClean);
+
+            FeedQuery query = new FeedQuery();
+            Service service = new Service();
+
+            if (uriToClean != null)
+            {
+                if (userName != null)
+                {
+                    NetworkCredential nc = new NetworkCredential(userName, 
pwd);
+                    service.Credentials = nc;
+                }
+
+                GDataLoggingRequestFactory factory = 
(GDataLoggingRequestFactory)this.factory;
+                factory.MethodOverride = true;
+                service.RequestFactory = this.factory; 
+
+                query.Uri = new Uri(uriToClean);
+
+                Tracing.TraceCall("Querying " + uriToClean);
+                AtomFeed feed = service.Query(query);
+                Tracing.TraceCall("Queryed " + uriToClean);
+                if (feed != null)
+                    Tracing.TraceCall("Entries: " + 
feed.Entries.Count.ToString());
+
+                int iCount = 0; 
+
+                if (feed.Entries.Count > 0)
+                {
+                    while (feed.Entries.Count > 0)
+                    {
+                        Tracing.TraceCall("Feed has still " + 
feed.Entries.Count.ToString() + " entries left.");
+                        foreach (AtomEntry entry in feed.Entries)
+                        {
+                            Tracing.TraceCall("Deleting entry " + iCount);
+                            entry.Delete();
+                            iCount++; 
+                            Tracing.TraceCall("Deleted entry " + iCount);
+                        }
+                        feed = service.Query(query);
+                    }
+
+                    Assert.AreEqual(0, feed.Entries.Count, "Feed should have 
no more entries, it has: " + feed.Entries.Count); 
+                    service.Credentials = null; 
+                    factory.MethodOverride = false;
+                }
+            }
+        }
+        
/////////////////////////////////////////////////////////////////////////////
        }
 }

Modified: trunk/clients/cs/src/unittests/blogger.cs
==============================================================================
--- trunk/clients/cs/src/unittests/blogger.cs   (original)
+++ trunk/clients/cs/src/unittests/blogger.cs   Wed May 30 15:51:41 2007
@@ -24,27 +24,17 @@
 using System.Web;
 using NUnit.Framework;
 using Google.GData.Client;
+using Google.GData.Client.UnitTests;
 using Google.GData.Extensions;
 using Google.GData.Calendar;
 
 
-
-
-namespace Google.GData.Client.UnitTests
+namespace Google.GData.Client.LiveTests
 {
     [TestFixture]
     [Category("LiveTest")]
-    public class BloggerTestSuite : BaseTestClass
+    public class BloggerTestSuite : BaseLiveTestClass
     {
-
-        /// <summary>holds the username to use</summary>
-        protected string userName;
-        /// <summary>holds the password to use</summary>
-        protected string passWord;
-
-        /// <summary>holds the default authhandler</summary> 
-        protected string strAuthHandler; 
-
         /// <summary>
         ///  test Uri for google calendarURI
         /// </summary>
@@ -93,25 +83,10 @@
         {
             base.ReadConfigFile();
 
-            if (unitTestConfiguration.Contains("authHandler") == true)
-            {
-                this.strAuthHandler = (string) 
unitTestConfiguration["authHandler"];
-                Tracing.TraceInfo("Read authHandler value: " + 
this.strAuthHandler);
-            }
             if (unitTestConfiguration.Contains("bloggerURI") == true)
             {
                 this.bloggerURI = (string) unitTestConfiguration["bloggerURI"];
                 Tracing.TraceInfo("Read bloggerURI value: " + this.bloggerURI);
-            }
-            if (unitTestConfiguration.Contains("userName") == true)
-            {
-                this.userName = (string) unitTestConfiguration["userName"];
-                Tracing.TraceInfo("Read userName value: " + this.userName);
-            }
-            if (unitTestConfiguration.Contains("passWord") == true)
-            {
-                this.passWord = (string) unitTestConfiguration["passWord"];
-                Tracing.TraceInfo("Read passWord value: " + this.passWord);
             }
         }
         
/////////////////////////////////////////////////////////////////////////////

Modified: trunk/clients/cs/src/unittests/caltest.cs
==============================================================================
--- trunk/clients/cs/src/unittests/caltest.cs   (original)
+++ trunk/clients/cs/src/unittests/caltest.cs   Wed May 30 15:51:41 2007
@@ -23,6 +23,7 @@
 using System.Net; 
 using NUnit.Framework;
 using Google.GData.Client;
+using Google.GData.Client.UnitTests;
 using Google.GData.Extensions;
 using Google.GData.Calendar;
 using Google.GData.AccessControl;
@@ -30,22 +31,12 @@
 
 
 
-namespace Google.GData.Client.UnitTests
+namespace Google.GData.Client.LiveTests
 {
     [TestFixture] 
-    [Category("GoogleCalendar")]
     [Category("LiveTest")]
-    public class CalendarTestSuite : BaseTestClass
+    public class CalendarTestSuite : BaseLiveTestClass
     {
-
-        /// <summary>holds the username to use</summary>
-        protected string userName;
-        /// <summary>holds the password to use</summary>
-        protected string passWord;
-
-        /// <summary>holds the default authhandler</summary> 
-        protected string strAuthHandler; 
-
         /// <summary>
         ///  test Uri for google calendarURI
         /// </summary>
@@ -74,6 +65,7 @@
         //////////////////////////////////////////////////////////////////////
         [SetUp] public override void InitTest()
         {
+            Tracing.TraceCall();
             base.InitTest(); 
             GDataGAuthRequestFactory authFactory = this.factory as 
GDataGAuthRequestFactory; 
             if (authFactory != null)
@@ -91,6 +83,7 @@
         //////////////////////////////////////////////////////////////////////
         [TearDown] public override void EndTest()
         {
+            Tracing.TraceCall();
             FeedCleanup(this.defaultCalendarUri, this.userName, this.passWord);
             Tracing.ExitTracing();
         }
@@ -106,11 +99,6 @@
         {
             base.ReadConfigFile();
 
-            if (unitTestConfiguration.Contains("authHandler") == true)
-            {
-                this.strAuthHandler = (string) 
unitTestConfiguration["authHandler"];
-                Tracing.TraceInfo("Read authHandler value: " + 
this.strAuthHandler);
-            }
             if (unitTestConfiguration.Contains("calendarURI") == true)
             {
                 this.defaultCalendarUri = (string) 
unitTestConfiguration["calendarURI"];
@@ -125,16 +113,6 @@
             {
                 this.defaultCompositeUri = (string) 
unitTestConfiguration["compositeURI"];
                 Tracing.TraceInfo("Read compositeURI value: " + 
this.defaultCompositeUri);
-            }
-            if (unitTestConfiguration.Contains("userName") == true)
-            {
-                this.userName = (string) unitTestConfiguration["userName"];
-                Tracing.TraceInfo("Read userName value: " + this.userName);
-            }
-            if (unitTestConfiguration.Contains("passWord") == true)
-            {
-                this.passWord = (string) unitTestConfiguration["passWord"];
-                Tracing.TraceInfo("Read passWord value: " + this.passWord);
             }
         }
         
/////////////////////////////////////////////////////////////////////////////

Modified: trunk/clients/cs/src/unittests/unittests.cs
==============================================================================
--- trunk/clients/cs/src/unittests/unittests.cs (original)
+++ trunk/clients/cs/src/unittests/unittests.cs Wed May 30 15:51:41 2007
@@ -96,60 +96,6 @@
         }
         
/////////////////////////////////////////////////////////////////////////////
 
-
-        //////////////////////////////////////////////////////////////////////
-        /// <summary>empty a feed</summary> 
-        //////////////////////////////////////////////////////////////////////
-        protected void FeedCleanup(String uriToClean, String userName, String 
pwd)
-        {
-            Tracing.TraceMsg("Entering BloggerCleanup");
-
-            FeedQuery query = new FeedQuery();
-            Service service = new Service();
-
-
-            if (uriToClean != null)
-            {
-                if (userName != null)
-                {
-                    NetworkCredential nc = new NetworkCredential(userName, 
pwd);
-                    service.Credentials = nc;
-                }
-
-                GDataLoggingRequestFactory factory = 
(GDataLoggingRequestFactory) this.factory;
-                factory.MethodOverride = true;
-                service.RequestFactory = this.factory; 
-
-                query.Uri = new Uri(uriToClean);
-                AtomFeed feed = service.Query(query);
-
-                int iCount=0; 
-
-                while (feed != null && feed.Entries.Count > 0)
-                {
-                    // look for the one with dinner time...
-                                       foreach (AtomEntry entry in 
feed.Entries)
-                                       {
-                                               entry.Delete(); 
-                        iCount++; 
-                        Tracing.TraceMsg("Blogger Cleanup = deleting entry" + 
iCount);
-                                       }
-                    // just query the same query again.
-                    feed = service.Query(query);
-                }
-
-                Tracing.Assert(feed.Entries.Count ==0, "Feed should be empty" 
); 
-
-                query.Uri = new Uri(uriToClean);
-                feed = service.Query(query);
-
-                Assert.AreEqual(0, feed.Entries.Count, "Feed should have no 
more entries, it has: " + feed.Entries.Count); 
-                service.Credentials = null; 
-                factory.MethodOverride = false;
-            }
-        }
-        
/////////////////////////////////////////////////////////////////////////////
-
         //////////////////////////////////////////////////////////////////////
         /// <summary>private void ReadConfigFile()</summary> 
         /// <returns> </returns>
@@ -339,13 +285,13 @@
         {
             Tracing.TraceMsg("Entering TestIt");
 
-            CalendarTestSuite  test = new CalendarTestSuite();
+            //CalendarTestSuite  test = new CalendarTestSuite();
            // BloggerTestSuite  test = new BloggerTestSuite();
             // CoreTestSuite test = new CoreTestSuite();
 
-            test.InitTest(); 
-            test.CalendarACLTest();
-            test.EndTest(); 
+//            test.InitTest(); 
+//            test.CalendarACLTest();
+//            test.EndTest(); 
 
 
 /*

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to