Example #1
0
        public void YouTubePageSizeTest()
        {
            Tracing.TraceMsg("Entering YouTubePageSizeTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed   = f.GetStandardFeed(YouTubeQuery.MostPopular);
            int          iCount = 0;

            // this will get you just the first 15 videos.
            foreach (Video v in feed.Entries)
            {
                iCount++;
                f.Settings.PageSize = 5;
                Feed <Comment> list = f.GetComments(v);
                int            i    = 0;
                foreach (Comment c in list.Entries)
                {
                    i++;
                }
                Assert.IsTrue(i <= 5, "the count should be smaller/equal 5");
                Assert.IsTrue(list.PageSize == -1 || list.PageSize == 5, "the returned pagesize should be 5 or -1 as well");
            }

            Assert.AreEqual(iCount, 15, "the outer feed should count 15");
            Assert.AreEqual(feed.PageSize, 15, "outer feed pagesize should be 15");
        }
Example #2
0
        public void YouTubeUnAuthenticatedRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubeUnAuthenticatedRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey);

            settings.AutoPaging = true;
            settings.Maximum    = 50;

            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            // this will get you the first 25 videos, let's retrieve comments for the first one only
            foreach (Video v in feed.Entries)
            {
                Feed <Comment> list = f.GetComments(v);
                foreach (Comment c in list.Entries)
                {
                    Assert.IsTrue(c.AtomEntry != null);
                    Assert.IsTrue(c.Title != null);
                }
                break;
            }
        }
Example #3
0
        ///////////////////////// START OF REQUEST TESTS



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubeRequestTest");


            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed get's you a users video feed
            Feed <Video> feed = f.GetVideoFeed(null);

            // this will get you just the first 25 videos.
            foreach (Video v in feed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
            }

            Feed <Video> sfeed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            int iCountOne = 0;

            // this loop get's you all videos in the mostpopular video feeed
            foreach (Video v in sfeed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
                iCountOne++;
            }
            int iCountTwo = 0;

            sfeed.AutoPaging = true;
            sfeed.Maximum    = 50;

            foreach (Video v in sfeed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
                iCountTwo++;
            }
            Assert.IsTrue(iCountTwo > iCountOne);
        }
Example #4
0
        public void YouTubeGetTest()
        {
            Tracing.TraceMsg("Entering YouTubeGetTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            foreach (Video v in feed.Entries)
            {
                // remove the etag to force a refresh
                v.YouTubeEntry.Etag = null;
                Video refresh = f.Retrieve(v);

                Assert.AreEqual(refresh.VideoId, v.VideoId, "The ID values should be equal");
            }
        }
Example #5
0
        public void YouTubeMaximumTest()
        {
            Tracing.TraceMsg("Entering YouTubeMaximumTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            settings.Maximum = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed   = f.GetStandardFeed(YouTubeQuery.MostPopular);
            int          iCount = 0;

            // this will get you just the first 15 videos.
            foreach (Video v in feed.Entries)
            {
                iCount++;
            }

            Assert.AreEqual(iCount, 15);
        }
Example #6
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeCommentRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubeCommentRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);
            YouTubeRequest         f        = new YouTubeRequest(settings);

            Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            // this will get you just the first 25 videos.
            foreach (Video v in feed.Entries)
            {
                Feed <Comment> list = f.GetComments(v);
                foreach (Comment c in list.Entries)
                {
                    Assert.IsTrue(c.AtomEntry != null);
                    Assert.IsTrue(c.Title != null);
                }
            }
        }
Example #7
0
        public void YouTubePagingTest()
        {
            Tracing.TraceMsg("Entering YouTubePagingTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            Feed <Video> prev = f.Get <Video>(feed, FeedRequestType.Prev);

            Assert.IsTrue(prev == null, "the first chunk should not have a prev");

            Feed <Video> next = f.Get <Video>(feed, FeedRequestType.Next);

            Assert.IsTrue(next != null, "the next chunk should exist");

            prev = f.Get <Video>(next, FeedRequestType.Prev);
            Assert.IsTrue(prev != null, "the prev chunk should exist now");
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeGetTest()
        {
            Tracing.TraceMsg("Entering YouTubeGetTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            foreach (Video v in feed.Entries)
            {
                // remove the etag to force a refresh
                v.YouTubeEntry.Etag = null;
                Video refresh = f.Retrieve(v);

                Assert.AreEqual(refresh.VideoId, v.VideoId, "The ID values should be equal");
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubePagingTest()
        {
            Tracing.TraceMsg("Entering YouTubePagingTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            Feed<Video> prev = f.Get<Video>(feed, FeedRequestType.Prev);
            Assert.IsTrue(prev == null, "the first chunk should not have a prev"); 

            Feed<Video> next = f.Get<Video>(feed, FeedRequestType.Next); 
            Assert.IsTrue(next != null, "the next chunk should exist"); 

            prev = f.Get<Video>(next, FeedRequestType.Prev);
            Assert.IsTrue(prev != null, "the prev chunk should exist now"); 

        }
        /////////////////////////////////////////////////////////////////////////////
        // 

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubePageSizeTest()
        {
            Tracing.TraceMsg("Entering YouTubePageSizeTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            int iCount = 0; 
            // this will get you just the first 15 videos. 
            foreach (Video v in feed.Entries)
            {
                iCount++;
                f.Settings.PageSize = 5; 
                Feed<Comment> list = f.GetComments(v);
                int i = 0; 
                foreach (Comment c in list.Entries)
                {
                    i++;
                }
                Assert.IsTrue(i <= 5, "the count should be smaller/equal 5"); 
                Assert.IsTrue(list.PageSize == -1 || list.PageSize == 5, "the returned pagesize should be 5 or -1 as well"); 
            }

            Assert.AreEqual(iCount, 15, "the outer feed should count 15");
            Assert.AreEqual(feed.PageSize, 15, "outer feed pagesize should be 15"); 

        }
        /////////////////////////////////////////////////////////////////////////////


          //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeUnAuthenticatedRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubeUnAuthenticatedRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey);
            settings.AutoPaging = true;
            settings.Maximum = 50; 

            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            // this will get you just the first 25 videos. 
            foreach (Video v in feed.Entries)
            {
                Feed<Comment> list= f.GetComments(v);
                foreach (Comment c in list.Entries)
                {
                    Assert.IsTrue(c.AtomEntry != null);
                    Assert.IsTrue(c.Title != null);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeMaximumTest()
        {
            Tracing.TraceMsg("Entering YouTubeMaximumTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            settings.Maximum = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            int iCount = 0; 
            // this will get you just the first 15 videos. 
            foreach (Video v in feed.Entries)
            {
                iCount++;
            }

            Assert.AreEqual(iCount, 15);

        }
        ///////////////////////// START OF REQUEST TESTS 



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeRequestTest()
        {
            Tracing.TraceMsg("Entering YouTubeRequestTest");


            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);

            YouTubeRequest f = new YouTubeRequest(settings);
            // GetVideoFeed get's you a users video feed
            Feed<Video> feed = f.GetVideoFeed(null);
            // this will get you just the first 25 videos. 
            foreach (Video v in feed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
            }

            Feed<Video> sfeed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            int iCountOne=0; 
            // this loop get's you all videos in the mostpopular video feeed
            foreach (Video v in sfeed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
                iCountOne++; 
            }
            int iCountTwo = 0; 
            sfeed.AutoPaging = true;
            sfeed.Maximum = 50; 

            foreach (Video v in sfeed.Entries)
            {
                Assert.IsTrue(v.AtomEntry != null, "There should be an atomentry");
                Assert.IsTrue(v.Title != null, "There should be a title");
                Assert.IsTrue(v.VideoId != null, "There should be a videoID");
                iCountTwo++; 
            }
            Assert.IsTrue(iCountTwo > iCountOne); 
        }
Example #14
0
        public void YouTubeCommentRequestTest() {
            Tracing.TraceMsg("Entering YouTubeCommentRequestTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);
            // this will get you the first 25 videos, let's retrieve comments for the first one only
            foreach (Video v in feed.Entries) {
                Feed<Comment> list = f.GetComments(v);
                foreach (Comment c in list.Entries) {
                    Assert.IsTrue(c.AtomEntry != null);
                    Assert.IsTrue(c.Title != null);
                }
                break;
            }
        }