Esempio n. 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);
            }
        }
Esempio n. 2
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_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);
        }
        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 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 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);
            }
        }
Esempio n. 7
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));
        }