コード例 #1
0
        /////////////////////////////////////////////////////////////////////////////



        ////////////////////////////////////////////////////////////////////
        /// <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");
            }
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <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));
            }
        }
コード例 #3
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <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");
            }
        }
コード例 #4
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <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);
        }
コード例 #5
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <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));
                }
            }
        }