示例#1
0
        public void UpdatePlaylist_Change_From_Smart_To_Explicit_Test()
        {
            BrightcoveItemCollection <BrightcovePlaylist> playlists = _api.FindAllPlaylists();

            // Look for the first NON-explicit (i.e. smart) playlist.
            BrightcovePlaylist playlist = playlists.FirstOrDefault(x => x.PlaylistType != PlaylistType.Explicit);

            if (playlist == null)
            {
                Assert.Fail("There are no smart playlists in the collection. Try creating an smart playlist first.");
            }
            else
            {
                // If it doesn't have any videos, add some to test the inclusion of the VideoIds property.
                if (!playlist.VideoIds.Any())
                {
                    BrightcoveItemCollection <BrightcoveVideo> videos = _api.FindAllVideos(4, 0);
                    playlist.VideoIds = videos.Select(x => x.Id).ToList();
                }

                // Make an explicit playlist.
                playlist.PlaylistType = PlaylistType.Explicit;
                ICollection <long> videoIds = playlist.VideoIds;
                playlist.VideoIds = new Collection <long>();

                BrightcovePlaylist updatedPlaylist = _api.UpdatePlaylist(playlist);
                Assert.AreEqual(playlist.PlaylistType, updatedPlaylist.PlaylistType);

                updatedPlaylist.VideoIds = videoIds;
                BrightcovePlaylist newUpdatedPlaylist = _api.UpdatePlaylist(updatedPlaylist);
                Assert.AreEqual(videoIds.Count, newUpdatedPlaylist.VideoIds.Count);
            }
        }
        public void Sort_Videos_By_DisplayName_Desc_Creation_Date_Asc_With_All_Any_None_Parameters()
        {
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos
                                                                (
                AllFieldValues,
                AnyFieldValues,
                NoneFieldValues,
                100,
                0,
                false,
                new SortedFieldDictionary(SortBy.DisplayName,
                                          SortOrder.Descending,
                                          SortBy.CreationDate,
                                          SortOrder.Ascending)
                                                                );

            List <BrightcoveVideo> expectedVideos = AllVideos
                                                    .Where(x => videos.Select(y => y.Id).Contains(x.Id))
                                                    .OrderByDescending(x => x.Name.Replace("-", "").Replace("_", "")) // Brightcove search doesn't seem to take dashes and underscores into consideration when ordering; perhaps all special characters?
                                                    .ThenBy(x => x.CreationDate)
                                                    .ToList();

            bool hasCorrectIndexes = expectedVideos
                                     .Select((x, i) => new
            {
                Id    = x.Id,
                Index = i
            })
                                     .All(x => x.Index == videos.IndexOf(videos.Single(y => y.Id == x.Id)));

            Assert.AreEqual(expectedVideos.Count, videos.Count);
            Assert.IsTrue(hasCorrectIndexes);
        }
示例#3
0
        public void UpdatePlaylist_Change_From_Explicit_To_Smart_Test()
        {
            BrightcoveItemCollection <BrightcovePlaylist> playlists = _api.FindAllPlaylists();

            // Look for the first Explicit playlist.
            BrightcovePlaylist playlist = playlists.LastOrDefault(x => x.PlaylistType == PlaylistType.Explicit);

            if (playlist == null)
            {
                Assert.Fail("There are no explicit playlists in the collection. Try creating an explicit playlist first.");
            }
            else
            {
                // If it doesn't have any videos, add some to test the inclusion of the VideoIds property.
                if (!playlist.VideoIds.Any())
                {
                    BrightcoveItemCollection <BrightcoveVideo> videos = _api.FindAllVideos(4, 0);
                    playlist.VideoIds = videos.Select(x => x.Id).ToList();
                }

                // Make a smart playlist of any sort.
                playlist.PlaylistType = PlaylistType.PlaysTotal;
                BrightcovePlaylist updatedPlaylist = _api.UpdatePlaylist(playlist);
                Assert.AreEqual(PlaylistType.PlaysTotal, updatedPlaylist.PlaylistType);
            }
        }
        public void Sort_Videos_By_Creation_Date_Desc_With_All_Any_None_Parameters()
        {
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos
                                                                (
                AllFieldValues,
                AnyFieldValues,
                NoneFieldValues,
                100,
                0,
                false,
                SortBy.CreationDate,
                SortOrder.Descending
                                                                );


            // Assume data is searched correctly based on the parameters, but check to see if the dates are in fact sorted correctly.
            List <BrightcoveVideo> expectedVideos = AllVideos
                                                    .Where(x => videos.Select(y => y.Id).Contains(x.Id))
                                                    .OrderByDescending(x => x.CreationDate)
                                                    .ToList();

            bool hasCorrectIndexes = expectedVideos
                                     .Select((x, i) => new
            {
                Id    = x.Id,
                Index = i
            })
                                     .All(x => x.Index == videos.IndexOf(videos.Single(y => y.Id == x.Id)));

            Assert.AreEqual(expectedVideos.Count, videos.Count);
            Assert.IsTrue(hasCorrectIndexes);
        }
        public void FindAllVideos()
        {
            Api = BrightcoveApiFactory.CreateApi(ApiKey);
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos(new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>());

            int k = 0;

            while (k <= Math.Floor((decimal)videos.TotalCount / (decimal)videos.PageSize))
            {
                if (k != 0)
                {
                    videos = Api.SearchVideos(new List <FieldValuePair>(),
                                              new List <FieldValuePair>(),
                                              new List <FieldValuePair>(),
                                              videos.PageSize,
                                              k);
                }

                AllVideos.AddRange(videos);

                k++;
            }
        }
        public void FindAudioTrackPlaylistsByReferenceIds_Basic_Test()
        {
            BrightcoveItemCollection <BrightcoveAudioTrackPlaylist> playlists = _api.FindAudioTrackPlaylistsByReferenceIds(new[] { _refId, _refId2 });

            Assert.NotNull(playlists);
            Assert.AreEqual(2, playlists.Count);
            Assert.AreEqual(1, playlists.Count(o => o != null));             // only _refId is a real reference Id in the system
        }
示例#7
0
        public void DeleteAudioTrackByIdTest()
        {
            BrightcoveItemCollection <BrightcoveAudioTrack> audioTracks = Api.FindAllAudioTracks();

            foreach (BrightcoveAudioTrack audioTrack in audioTracks)
            {
                Api.DeleteAudioTrack(audioTrack.Id, true, true);
            }
        }
示例#8
0
        public void FindAudioTracksByPlaylistIds_Basic_Test()
        {
            _playlists = _api.FindAllAudioTrackPlaylists(1, 0);
            BrightcoveItemCollection <BrightcoveAudioTrackPlaylist> playlists = _api.FindAudioTrackPlaylistsByIds(new[] { _playlists.First().Id, long.MaxValue });

            Assert.NotNull(playlists);
            Assert.AreEqual(2, playlists.Count);
            Assert.AreEqual(1, playlists.Count(o => o != null));             // only one playlist is in the system
        }
        public void UpdateAudioTrackInformation_ReferenceId_Test()
        {
            BrightcoveItemCollection <BrightcoveAudioTrack> audioTracks = Api.FindAllAudioTracks();

            BrightcoveAudioTrack audioTrack = audioTracks.Single(x => x.LongDescription.Contains("arbor"));             // arbor for pearl hARBOR

            // Change the reference Id
            audioTrack.ReferenceId = "FDR-Pearl-Harbor";
            BrightcoveAudioTrack result = Api.UpdateAudioTrack(audioTrack);

            Assert.AreEqual(audioTrack.ReferenceId, result.ReferenceId);
        }
        public void UpdateAudioTrackInformation_Tags_Test()
        {
            BrightcoveItemCollection <BrightcoveAudioTrack> audioTracks = Api.FindAllAudioTracks();

            BrightcoveAudioTrack audioTrack = audioTracks.Single(x => x.LongDescription.Contains("arbor"));             // arbor for pearl hARBOR

            // Make sure the tag property changes.
            string[] tags = audioTrack.Tags.Any() ? new string[] { } : new[] { "War", "world-war-two", "Japan", "president" };
            audioTrack.Tags = tags;
            BrightcoveAudioTrack result = Api.UpdateAudioTrack(audioTrack);

            Assert.IsTrue(tags.OrderBy(x => x).SequenceEqual(result.Tags.OrderBy(x => x)));
        }
		public void Deserialize_Video_Test_Basic()
		{
			JavaScriptSerializer serializer = BrightcoveSerializerFactory.GetSerializer();
			IDictionary<string, object> dictionary = new Dictionary<string, object>();
			var testrenditionCollection = new BrightcoveItemCollection<BrightcoveRendition>();
			var testrendition = new BrightcoveRendition();
			testrendition.ControllerType = ControllerType.AkamaiHd;
			testrenditionCollection.Add(testrendition);
			dictionary.Add("renditions", testrenditionCollection);

			var renditions =
				serializer.ConvertToType<BrightcoveItemCollection<BrightcoveRendition>>(dictionary["renditions"]);
			Assert.That(renditions[0].ControllerType, Is.EqualTo(ControllerType.AkamaiHd));
		}
 public void Sort_Videos_With_Odd_Number_Sort_Params()
 {
     // Perform the API call
     BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos
                                                         (
         AllFieldValues,
         AnyFieldValues,
         NoneFieldValues,
         100,
         0,
         false,
         new SortedFieldDictionary(SortBy.DisplayName,
                                   SortOrder.Descending,
                                   SortBy.CreationDate)
                                                         );
 }
示例#13
0
        public void Deserialize_Video_Test_Basic()
        {
            JavaScriptSerializer         serializer = BrightcoveSerializerFactory.GetSerializer();
            IDictionary <string, object> dictionary = new Dictionary <string, object>();
            var testrenditionCollection             = new BrightcoveItemCollection <BrightcoveRendition>();
            var testrendition = new BrightcoveRendition();

            testrendition.ControllerType = ControllerType.AkamaiHd;
            testrenditionCollection.Add(testrendition);
            dictionary.Add("renditions", testrenditionCollection);

            var renditions =
                serializer.ConvertToType <BrightcoveItemCollection <BrightcoveRendition> >(dictionary["renditions"]);

            Assert.That(renditions[0].ControllerType, Is.EqualTo(ControllerType.AkamaiHd));
        }
        public void Sort_Videos_By_Creation_Date_No_Parameters()
        {
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos(new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>());

            BrightcoveVideo firstVideo         = videos.First();
            BrightcoveVideo expectedFirstVideo = AllVideos.OrderBy(x => x.CreationDate)
                                                 .First();
            BrightcoveVideo lastVideoOnPage          = videos.Last();
            BrightcoveVideo expectedLastVideoInRange = AllVideos.OrderBy(x => x.CreationDate)
                                                       .Skip(videos.PageSize - 1)
                                                       .First();

            Assert.AreEqual(expectedFirstVideo.Id, firstVideo.Id);
            Assert.AreEqual(expectedLastVideoInRange.Id, lastVideoOnPage.Id);
        }
        public void UpdateAudioTrackPlaylist_Test_Change_From_Explicit_To_Smart()
        {
            BrightcoveItemCollection <BrightcoveAudioTrackPlaylist> playlists = _api.FindAllAudioTrackPlaylists();

            // look for the first Explicit playlist
            BrightcoveAudioTrackPlaylist playlist = playlists.FirstOrDefault(x => x.PlaylistType == PlaylistType.Explicit);

            if (playlist == null)
            {
                Assert.Fail("There are no explicit playlists in the collection. Try creating an explicit playlist first.");
            }
            else
            {
                // Make a smart playlist of any sort.
                playlist.PlaylistType = PlaylistType.Alphabetical;
                BrightcoveAudioTrackPlaylist updatedPlaylist = _api.UpdateAudioTrackPlaylist(playlist);
                Assert.AreEqual(playlist.PlaylistType, updatedPlaylist.PlaylistType);
            }
        }
示例#16
0
        public void FindAllVideos_Test_SortOrder()
        {
            _videos = _api.FindAllVideos(10, 0, SortBy.CreationDate, SortOrder.Descending);
            Assert.AreEqual(10, _videos.Count);

            BrightcoveItemCollection <BrightcoveVideo> videos = _api.FindAllVideos(10, 0, SortBy.PlaysTotal, SortOrder.Descending);

            // verify each video's creation date is in order
            BrightcoveVideo lastVideo = null;

            foreach (BrightcoveVideo bcVideo in _videos)
            {
                if (lastVideo == null)
                {
                    lastVideo = bcVideo;
                    continue;
                }
                Assert.GreaterOrEqual(lastVideo.CreationDate, bcVideo.CreationDate);
                lastVideo = bcVideo;
            }
        }
        public void Sort_Videos_By_None_Desc_Creation_Date_Asc_With_All_Any_None_Parameters()
        {
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos(new List <FieldValuePair>
            {
                new FieldValuePair(null, "sea")
            },
                                                                                 new List <FieldValuePair>
            {
                new FieldValuePair(null, "lion"),
                new FieldValuePair(null, "clown"),
                new FieldValuePair(null, "crab"),
                new FieldValuePair(null, "turtle"),
                new FieldValuePair(null, "seagulls")
            },
                                                                                 new List <FieldValuePair>
            {
                new FieldValuePair(null, "fish")
            },
                                                                                 100,
                                                                                 0,
                                                                                 false,
                                                                                 new SortedFieldDictionary(SortBy.None, SortOrder.Descending, SortBy.CreationDate, SortOrder.Ascending));

            List <BrightcoveVideo> expectedVideos = AllVideos
                                                    .Where(x => videos.Select(y => y.Id).Contains(x.Id))
                                                    .OrderBy(x => x.CreationDate)
                                                    .ToList();

            bool hasCorrectIndexes = expectedVideos
                                     .Select((x, i) => new
            {
                Id    = x.Id,
                Index = i
            })
                                     .All(x => x.Index == videos.IndexOf(videos.Single(y => y.Id == x.Id)));

            Assert.AreEqual(expectedVideos.Count, videos.Count);
            Assert.IsTrue(hasCorrectIndexes);
        }
        public void Sort_Videos_By_Creation_Date_Desc_No_Parameters()
        {
            // Perform the API call
            BrightcoveItemCollection <BrightcoveVideo> videos = Api.SearchVideos(new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>(),
                                                                                 new List <FieldValuePair>(),
                                                                                 100,
                                                                                 0,
                                                                                 false,
                                                                                 SortBy.CreationDate,
                                                                                 SortOrder.Descending);

            BrightcoveVideo firstVideo         = videos.First();
            BrightcoveVideo expectedFirstVideo = AllVideos.OrderByDescending(x => x.CreationDate)
                                                 .First();
            BrightcoveVideo lastVideoOnPage          = videos.Last();
            BrightcoveVideo expectedLastVideoInRange = AllVideos.OrderByDescending(x => x.CreationDate)
                                                       .Skip(videos.PageSize - 1)
                                                       .First();

            Assert.AreEqual(videos.TotalCount, AllVideos.Count);
            Assert.AreEqual(expectedFirstVideo.Id, firstVideo.Id);
        }
        public void UpdateAudioTrackPlaylist_Test_Change_From_Smart_To_Explicit()
        {
            BrightcoveItemCollection <BrightcoveAudioTrackPlaylist> playlists = _api.FindAllAudioTrackPlaylists();

            // look for the first NON-Explicit playlist (smart)
            BrightcoveAudioTrackPlaylist playlist = playlists.FirstOrDefault(x => x.PlaylistType != PlaylistType.Explicit);

            if (playlist == null)
            {
                Assert.Fail("There are no smart playlists in the collection. Try creating an smart playlist first.");
            }
            else
            {
                // If it doesn't have any audio tracks, add some to test the inclusion of the VideoIds property.
                if (!playlist.AudioTrackIds.Any())
                {
                    BrightcoveItemCollection <BrightcoveAudioTrack> audioTracks = _api.FindAllAudioTracks(4, 0);
                    playlist.AudioTrackIds = audioTracks.Select(x => x.Id).ToList();
                }

                // Make an explicit playlist.
                playlist.PlaylistType = PlaylistType.Explicit;

                //Apply workaround.
                ICollection <long> audioTracksIds = playlist.AudioTrackIds;
                playlist.AudioTrackIds = new Collection <long>();

                BrightcoveAudioTrackPlaylist updatedPlaylist = _api.UpdateAudioTrackPlaylist(playlist);
                Assert.AreEqual(playlist.PlaylistType, updatedPlaylist.PlaylistType);

                // Re-update playlist
                updatedPlaylist.AudioTrackIds = audioTracksIds;
                BrightcoveAudioTrackPlaylist reUpdatedPlaylist = _api.UpdateAudioTrackPlaylist(updatedPlaylist);
                Assert.AreEqual(audioTracksIds.Count, reUpdatedPlaylist.AudioTrackIds.Count);
            }
        }
示例#20
0
        public void CreateAudioTrackPlaylist_Test_Basic()
        {
            BrightcoveItemCollection <BrightcoveAudioTrack> audioTracks = _api.FindAllAudioTracks(4, 0);
            BrightcoveAudioTrackPlaylist playlist = new BrightcoveAudioTrackPlaylist
            {
                Name        = "Test Audio Playlist",
                ReferenceId = "new-reference-id-5" + RandomString(8),
                // Get a list of random audio tracks to add to the playlist.
                AudioTrackIds    = audioTracks.Select(x => x.Id).ToList(),
                ShortDescription = "This is a playlist's short description",
                PlaylistType     = PlaylistType.Explicit,
                FilterTags       = new[] { "president" }
            };

            long newId = _api.CreateAudioTrackPlaylist(playlist);
            BrightcoveAudioTrackPlaylist newPlaylist = _api.FindAudioTrackPlaylistById(newId);

            Assert.AreEqual(playlist.Name, newPlaylist.Name);
            Assert.AreEqual(playlist.ReferenceId, newPlaylist.ReferenceId);
            Assert.AreEqual(playlist.ShortDescription, newPlaylist.ShortDescription);
            Assert.AreEqual(audioTracks.Count, newPlaylist.AudioTrackIds.Count);
            Assert.AreEqual(audioTracks.Count, newPlaylist.AudioTracks.Count);
            Assert.AreEqual(audioTracks.Count, newPlaylist.AudioTracks.Count(o => o != null));
        }