/////////////////////////////////////////////////////////////////////////////



        ////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateEmptyEntrySaveAndLoad()
        {
            Tracing.TraceMsg("Entering Create/Save/Load test");

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Content.Type    = "text";
            entry.Content.Content = "";

            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateEmptyEntrySaveAndLoad"));


            // let's try loading this...
            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateEmptyEntrySaveAndLoad"));
            AtomFeed feed = service.Query(query);

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
            // that feed should have ONE entry
            if (feed.Entries != null)
            {
                AtomEntry theOtherEntry = feed.Entries[0];
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry), "Entries should be identical");
            }
        }
        /////////////////////////////////////////////////////////////////////////////


        ////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new feed, saves and loads it back</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateFeedObjectSaveAndLoad()
        {
            Tracing.TraceMsg("Entering CreateFeedObjectSaveAndLoad test");

            Service  service = new Service();
            AtomFeed feed    = new AtomFeed(new Uri("http://www.atomfeed.com/"), service);

            feed.Self      = "http://www.atomfeed.com/self";
            feed.Feed      = "http://www.atomfeed.com/feed";
            feed.NextChunk = "http://www.atomfeed.com/next";
            feed.PrevChunk = "http://www.atomfeed.com/prev";
            feed.Post      = "http://www.atomfeed.com/post";

            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("CreateFeedSaveAndLoad"));


            // let's try loading this...
            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateFeedSaveAndLoad"));

            feed = service.Query(query);


            Assert.AreEqual("http://www.atomfeed.com/self", feed.Self, "Feed.Self is not correct");
            Assert.AreEqual("http://www.atomfeed.com/feed", feed.Feed, "Feed.Feed is not correct");
            Assert.AreEqual("http://www.atomfeed.com/next", feed.NextChunk, "Feed.Next is not correct");
            Assert.AreEqual("http://www.atomfeed.com/prev", feed.PrevChunk, "Feed.Prev is not correct");
            Assert.AreEqual("http://www.atomfeed.com/post", feed.Post, "Feed.Post is not correct");
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back
        ///   uses HTML content to test the persistence/encoding code
        /// </summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateHTMLEntrySaveAndLoad()
        {
            Tracing.TraceMsg("Entering CreateHTMLEntrySaveAndLoad");

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Content.Type    = "html";
            entry.Content.Content = HttpUtility.HtmlDecode("<b>this is a &lt;test&gt;</b>");

            Tracing.TraceMsg("Content: " + entry.Content.Content);

            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateHTMLEntrySaveAndLoad"));


            // let's try loading this...
            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateHTMLEntrySaveAndLoad"));
            AtomFeed feed = service.Query(query);

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
            // that feed should have ONE entry
            if (feed.Entries != null)
            {
                AtomEntry theOtherEntry = feed.Entries[0];
                Tracing.TraceMsg("Loaded Content: " + theOtherEntry.Content.Content);
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back
        ///   uses XHTML content to test the persistence/encoding code
        /// </summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateXHTMLEntrySaveAndLoad()
        {
            Tracing.TraceMsg("Entering CreateXHTMLEntrySaveAndLoad");

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Content.Type    = "xhtml";
            entry.Content.Content = HttpUtility.HtmlDecode("<div xmlns=\"http://www.w3.org/2005/Atom\"><b>this is a test</b></div>");

            Tracing.TraceMsg("Content: " + entry.Content.Content);

            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateXHTMLEntrySaveAndLoad"));

            Tracing.TraceMsg("saved in... CreateXHTMLEntrySaveAndLoad");


            // let's try loading this...
            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateXHTMLEntrySaveAndLoad"));
            AtomFeed feed = service.Query(query);

            Tracing.TraceMsg("loaded in... CreateXHTMLEntrySaveAndLoad");

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");


            // that feed should have ONE entry
            if (feed.Entries != null)
            {
                Tracing.TraceMsg("checking entries... CreateXHTMLEntrySaveAndLoad");
                AtomEntry theOtherEntry = feed.Entries[0];

                Assert.IsTrue(theOtherEntry.Content != null, "the entry should have a content element");
                Assert.IsTrue(theOtherEntry.Content.Type.Equals("xhtml"), "the entry should have a content element of type xhtml");
                Assert.IsTrue(theOtherEntry.Content.Content != null, "the entry should have a content element that is not empty");

                Tracing.TraceMsg("Loaded Content: " + theOtherEntry.Content.Content);
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
                Tracing.TraceMsg("done comparing entries... CreateXHTMLEntrySaveAndLoad");
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] queries the remote feed, saves it, loads it and compares it</summary>
        /// <param name="uriToQuery">the host to access, including query parameters</param>
        //////////////////////////////////////////////////////////////////////
        internal void RemoteHostQueryAndCompare(Uri uriToQuery)
        {
            Tracing.TraceMsg("Entering RemoteHostQueryAndCompare");

            int       iCount = 0;
            FeedQuery query  = new FeedQuery();

            query.Uri = uriToQuery;

            Service service = new Service();

            service.RequestFactory = this.factory;

            AtomFeed f = service.Query(query);

            ObjectModelHelper.DumpAtomObject(f, CreateDumpFileName("QueryRemoteHost"));

            iCount = f.Entries.Count;

            // let's try loading this...
            Service   service2 = new Service();
            FeedQuery query2   = new FeedQuery();

            query2.Uri = new Uri(CreateUriLogFileName("QueryRemoteHost"));

            AtomFeed feed = service2.Query(query2);

            Assert.AreEqual(iCount, feed.Entries.Count, "loaded feed has different number of entries");


            Tracing.TraceInfo("Comparing feed objects as source");
            Assert.IsTrue(ObjectModelHelper.IsSourceIdentical(f, feed), "Feeds are not identical");
            if (feed.Entries != null)
            {
                AtomEntry theOtherEntry;

                Tracing.TraceInfo("Comparing Entries");
                for (int i = 0; i < feed.Entries.Count; i++)
                {
                    theOtherEntry = feed.Entries[i];
                    Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(f.Entries[i], theOtherEntry), "Entries are not identical");
                }
            }

            Tracing.TraceInfo("Leaving RemoteHostQueryAndCompare for : " + uriToQuery.AbsoluteUri);
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a feed object from scratch</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateFeed()
        {
            Tracing.TraceInfo("Entering Create Feed Test");
            AtomFeed feed = new AtomFeed(new Uri("http://dummy"), null);

            AtomEntry entry;

            for (int i = 1; i <= this.iIterations; i++)
            {
                entry = ObjectModelHelper.CreateAtomEntry(i);
                feed.Entries.Add(entry);
            }

            Tracing.TraceInfo("now persisting feed");

            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("CreateFeed"));

            Tracing.TraceInfo("now loadiing feed from disk");

            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateFeed"));

            feed = service.Query(query);

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(this.iIterations, feed.Entries.Count, "Feed.Entries should have 50 elements");
            if (feed.Entries != null)
            {
                for (int i = 1; i <= this.iIterations; i++)
                {
                    entry = ObjectModelHelper.CreateAtomEntry(i);
                    AtomEntry theOtherEntry = feed.Entries[i - 1];
                    Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a number or rows and delets them again</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void DefaultHostExtensionTest()
        {
            Tracing.TraceMsg("Entering DefaultHostExtensionTest");

            if (this.strRemoteHost != null)
            {
                FeedQuery query   = new FeedQuery();
                Service   service = new Service();

                service.NewAtomEntry        += new FeedParserEventHandler(this.OnParsedNewEntry);
                service.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);


                service.RequestFactory = (IGDataRequestFactory) new GDataLoggingRequestFactory(this.ServiceName, this.ApplicationName);

                query.Uri = new Uri(this.strRemoteHost);

                AtomFeed returnFeed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(returnFeed, CreateDumpFileName("ExtensionFeed"));
            }
        }