Esempio n. 1
0
        /// <summary>
        /// Updates a playlist, specified by playlist ID or reference ID. Either a playlist ID or a reference ID must be
        /// supplied. If you are updating the value of the reference ID, then both the playlist ID and reference ID must be supplied.
        /// </summary>
        /// <param name="playlist">The playlist you'd like to update.</param>
        /// <returns>The playlist that was updated</returns>
        public BrightcovePlaylist UpdatePlaylist(BrightcovePlaylist playlist)
        {
            BrightcoveParamCollection parms = CreateWriteParamCollection("update_playlist",
                                                                         methodParams => methodParams.Add("playlist", playlist));

            return(RunPost <BrightcoveResultContainer <BrightcovePlaylist> >(parms).Result);
        }
        public void DeletePlaylist_Test_Basic()
        {
            // create a playlist that will later be deleted
            BrightcovePlaylist playlist = new BrightcovePlaylist();

            playlist.Name             = "Test Playlist";
            playlist.ShortDescription = "Test Short Description";
            playlist.VideoIds.Add(1964394725001);
            playlist.VideoIds.Add(1964394726001);

            // perform the API call, verify the results
            long newId = _api.CreatePlaylist(playlist);
            BrightcovePlaylist newPlaylist = _api.FindPlaylistById(newId);

            Assert.AreEqual(playlist.Name, newPlaylist.Name);
            Assert.AreEqual(playlist.ShortDescription, newPlaylist.ShortDescription);
            Assert.AreEqual(playlist.VideoIds.Count, newPlaylist.VideoIds.Count);
            Assert.IsTrue(playlist.VideoIds.Contains(1964394725001));
            Assert.IsTrue(playlist.VideoIds.Contains(1964394726001));

            // now delete it
            _api.DeletePlaylist(newId, true);

            // verify it's gone
            // NOTE: The API must do some caching or something, cause this is still returning a result
            // NOTE: even though the playlist has indeed been deleted.
            // TODO: Can we verify the deletion without waiting for the cache to expire?
            //Assert.IsNull(_api.FindPlaylistById(newId));
        }
Esempio n. 3
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. 4
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);
            }
        }
Esempio n. 5
0
        public void FindPlaylistByRefereceId_Test_Basic()
        {
            BrightcovePlaylist playlist = _api.FindPlaylistByReferenceId("1963943648001");

            Assert.NotNull(playlist);
            Assert.Greater(playlist.VideoIds.Count, 0);
            Assert.Greater(playlist.Videos.Count, 0);
        }
Esempio n. 6
0
        public void FindPlaylistById_Test_Basic()
        {
            BrightcovePlaylist playlist = _api.FindPlaylistById(1963943649001);

            Assert.NotNull(playlist);
            Assert.Greater(playlist.VideoIds.Count, 0);
            Assert.Greater(playlist.Videos.Count, 0);
        }
        public void CreatePlaylist_Test_Basic()
        {
            BrightcovePlaylist playlist = new BrightcovePlaylist
            {
                Name             = "Testing something else",
                ShortDescription = "Test Short Description"
            };

            playlist.VideoIds.Add(1964394725001);
            playlist.VideoIds.Add(1964394737001);

            long newId = _api.CreatePlaylist(playlist);
            BrightcovePlaylist newPlaylist = _api.FindPlaylistById(newId);

            Assert.AreEqual(playlist.Name, newPlaylist.Name);
            Assert.AreEqual(playlist.ShortDescription, newPlaylist.ShortDescription);
            Assert.AreEqual(playlist.VideoIds.Count, newPlaylist.VideoIds.Count);
            Assert.IsTrue(playlist.VideoIds.Contains(1964394725001));
            Assert.IsTrue(playlist.VideoIds.Contains(1964394726001));
            Assert.IsTrue(playlist.VideoIds.Contains(1964394737001));
        }
Esempio n. 8
0
        public void UpdatePlaylist_Test_Basic()
        {
            BrightcovePlaylist playlist = _api.FindPlaylistById(1989037682001);

            Assert.NotNull(playlist);

            playlist.Name             = "Renamed Test Playlist";
            playlist.ShortDescription = "New short description";
            playlist.PlaylistType     = PlaylistType.Explicit;

            const long vidId = 1964441418001;

            // Remove or add the video, depending on whether it was already there
            bool isPresent = !playlist.VideoIds.Contains(vidId);

            if (isPresent)
            {
                playlist.VideoIds.Remove(vidId);
            }
            else
            {
                playlist.VideoIds.Add(vidId);
            }

            BrightcovePlaylist returnedPlaylist = _api.UpdatePlaylist(playlist);

            Assert.AreEqual(playlist.Name, returnedPlaylist.Name);
            Assert.AreEqual(playlist.ShortDescription, returnedPlaylist.ShortDescription);
            Assert.AreEqual(playlist.VideoIds.Count, returnedPlaylist.VideoIds.Count);

            if (isPresent)
            {
                Assert.That(returnedPlaylist.VideoIds, Is.Not.Contains(vidId));
            }
            else
            {
                Assert.That(returnedPlaylist.VideoIds, Contains.Item(vidId));
            }
        }