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