示例#1
0
        public void GetSharedPlaylist_PlaylistShareCodeExists_CopyOfPlaylistCreated()
        {
            User user = Helpers.CreateUser();

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            ShareCode shareCode = ShareCodeManager.GetShareCode(ShareableEntityType.Playlist, user.Playlists.First().Id);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            //  Create a new playlist for the given user by loading up the playlist via sharecode.
            var result = (JsonServiceStackResult)PlaylistController.CreateCopyByShareCode(shareCode.ShortId, shareCode.UrlFriendlyEntityTitle, user.Id);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            var playlistDto = (PlaylistDto)result.Data;

            //  Make sure we actually get a Playlist DTO back from the Controller.
            Assert.NotNull(playlistDto);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            User userFromDatabase = UserDao.Get(playlistDto.UserId);

            //  Make sure that the created playlist was cascade added to the User
            Assert.That(userFromDatabase.Playlists.Count(p => p.Id == playlistDto.Id) == 1);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
        }
示例#2
0
        public void GetSharedPlaylist_PlaylistShareCodeExists_CopyOfPlaylistCreated()
        {
            Folder folder = UserManager.CreateUser().Folders.First();

            ShareCode shareCode = ShareCodeManager.GetShareCode(ShareableEntityType.Playlist, folder.Playlists.First().Id);

            JsonDataContractActionResult result = (JsonDataContractActionResult)PlaylistController.CreateCopyByShareCode(shareCode.ShortId, shareCode.UrlFriendlyEntityTitle, folder.Id);
            PlaylistDto playlistDto             = (PlaylistDto)result.Data;

            //  Make sure we actually get a Playlist DTO back from the Controller.
            Assert.NotNull(playlistDto);

            NHibernateSessionManager.Instance.Clear();

            Folder folderFromDatabase = FolderDao.Get(playlistDto.FolderId);

            //  Make sure that the created playlist was cascade added to the Folder
            Assert.That(folderFromDatabase.Playlists.Count(p => p.Id == playlistDto.Id) == 1);
        }
        public void GetSharedPlaylist_PlaylistShareCodeExists_CopyOfPlaylistCreated()
        {
            User user = Helpers.CreateUser();

            Playlist  playlist  = PlaylistManager.CopyAndSave(user.Playlists.First().Id);
            ShareCode shareCode = ShareCodeManager.GetShareCode(playlist);

            ShareCodeRequestDto shareCodeRequestDto = new ShareCodeRequestDto(user.Id, shareCode.ShortId, shareCode.UrlFriendlyEntityTitle);

            //  Create a new playlist for the given user by loading up the playlist via sharecode.
            var playlistDto = PlaylistController.CreateCopyByShareCode(shareCodeRequestDto);

            //  Make sure we actually get a Playlist DTO back from the Controller.
            Assert.NotNull(playlistDto);

            User userFromDatabase = UserManager.Get(playlistDto.UserId);

            //  Make sure that the created playlist was cascade added to the User
            Assert.That(userFromDatabase.Playlists.Count(p => p.Id == playlistDto.Id) == 1);
        }