public void Create50PlaylistItems_PlaylistEmpty_AllItemsCreated()
        {
            const int numItemsToCreate = 50;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            var result = PlaylistItemController.CreateMultiple(playlistItemDtos);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            var createdPlaylistItemDtos = (List <PlaylistItemDto>)result.Data;

            //  Make sure we actually get the list back from the Controller.
            Assert.NotNull(createdPlaylistItemDtos);
            Assert.That(createdPlaylistItemDtos.Count == numItemsToCreate);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();

            Playlist playlist = PlaylistDao.Get(playlistItemDtos.First().PlaylistId);

            //  Make sure that the created playlistItem was cascade added to the Playlist
            Assert.That(playlist.Items.Count == numItemsToCreate);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
        }
        public void GetUserWithBulkPlaylistItems_UserCreatedWithLotsOfItems_UserHasOnePlaylist()
        {
            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            JsonServiceStackResult result = (JsonServiceStackResult)UserController.Create();

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            UserDto createdUserDto = (UserDto)result.Data;

            const int numItemsToCreate = 2000;

            Guid playlistId = createdUserDto.Playlists.First().Id;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate, playlistId);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            PlaylistItemController.CreateMultiple(playlistItemDtos);
            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();

            User userFromDatabase = UserDao.Get(createdUserDto.Id);

            Assert.That(userFromDatabase.Playlists.Count == createdUserDto.Playlists.Count);
            Assert.That(userFromDatabase.Playlists.First().Items.Count() == numItemsToCreate);

            //  Different sessions -- first should be de-synced from the second.
            Assert.That(userFromDatabase.Playlists.First().Items.Count() != createdUserDto.Playlists.First().Items.Count());
        }
Example #3
0
        public void DeletePlaylist_NextToBigPlaylist_NoStackOverflowException()
        {
            User user = Helpers.CreateUser();

            Guid firstPlaylistId = user.Playlists.First().Id;

            PlaylistDto playlistDto = Helpers.CreatePlaylistDto(user.Id);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            var result = (JsonServiceStackResult)PlaylistController.Create(playlistDto);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            var createdPlaylistDto = (PlaylistDto)result.Data;

            const int numItemsToCreate = 150;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate,
                                                                                     createdPlaylistDto.Id);

            foreach (var splitPlaylistItemDtos in Split(playlistItemDtos, 50))
            {
                NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
                PlaylistItemController.CreateMultiple(splitPlaylistItemDtos);
                NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
            }

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            //  Now delete the first playlist.
            PlaylistController.Delete(firstPlaylistId);
            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
        }
Example #4
0
        public void Create50PlaylistItems_PlaylistEmpty_AllItemsCreated()
        {
            const int numItemsToCreate = 50;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate);

            var createdPlaylistItemDtos = PlaylistItemController.CreateMultiple(playlistItemDtos);

            //  Make sure we actually get the list back from the Controller.
            Assert.NotNull(createdPlaylistItemDtos);
            Assert.That(createdPlaylistItemDtos.Count() == numItemsToCreate);

            Playlist playlist = PlaylistManager.Get(playlistItemDtos.First().PlaylistId);

            //  Make sure that the created playlistItem was cascade added to the Playlist
            Assert.That(playlist.Items.Count == numItemsToCreate);
        }
        public void GetUserWithBulkPlaylistItems_UserCreatedWithLotsOfItems_UserHasOnePlaylist()
        {
            JsonResult result = UserController.Create();

            var createdUserDto = (UserDto)result.Data;

            const int numItemsToCreate = 2000;

            Guid playlistId = createdUserDto.Playlists.First().Id;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate, playlistId);

            PlaylistItemController.CreateMultiple(playlistItemDtos);

            User userFromDatabase = UserManager.Get(createdUserDto.Id);

            Assert.That(userFromDatabase.Playlists.Count == createdUserDto.Playlists.Count);
            Assert.That(userFromDatabase.Playlists.First().Items.Count() == numItemsToCreate);
        }
Example #6
0
        public void GetUserWithBulkPlaylistItemsInFolder_UserCreatedWithLotsOfItems_UserHasOneFolderOnePlaylist()
        {
            User user = UserManager.CreateUser();

            const int numItemsToCreate = 2000;

            Guid playlistId = user.Folders.First().Playlists.First().Id;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate, playlistId);

            PlaylistItemController.CreateMultiple(playlistItemDtos);

            NHibernateSessionManager.Instance.Clear();

            User userFromDatabase = UserDao.Get(user.Id);

            Assert.That(userFromDatabase.Folders.Count == user.Folders.Count);
            Assert.That(userFromDatabase.Folders.First().Playlists.Count == user.Folders.First().Playlists.Count);
            Assert.That(userFromDatabase.Folders.First().Playlists.First().Items.Count() == numItemsToCreate);
            Assert.That(userFromDatabase.Folders.First().Playlists.First().Items.Count() == user.Folders.First().Playlists.First().Items.Count());
        }
        public void DeletePlaylist_NextToBigPlaylist_NoStackOverflowException()
        {
            User user = Helpers.CreateUser();

            Guid firstPlaylistId = user.Playlists.First().Id;

            PlaylistDto playlistDto = Helpers.CreatePlaylistDto(user.Id, "Title");

            var createdPlaylistDto = PlaylistController.Create(playlistDto);

            const int numItemsToCreate = 150;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate, createdPlaylistDto.Id);

            foreach (var splitPlaylistItemDtos in Split(playlistItemDtos, 50))
            {
                PlaylistItemController.CreateMultiple(splitPlaylistItemDtos);
            }

            //  Now delete the first playlist.
            PlaylistController.Delete(firstPlaylistId);
        }
Example #8
0
        public void DeletePlaylist_NextToBigPlaylist_NoStackOverflowException()
        {
            Folder folder          = UserManager.CreateUser().Folders.First();
            Guid   firstPlaylistId = folder.Playlists.First().Id;

            PlaylistDto playlistDto             = Helpers.CreatePlaylistDto(folder.Id);
            JsonDataContractActionResult result = (JsonDataContractActionResult)PlaylistController.Create(playlistDto);
            PlaylistDto createdPlaylistDto      = (PlaylistDto)result.Data;

            const int numItemsToCreate = 150;
            List <PlaylistItemDto> playlistItemDtos = Helpers.CreatePlaylistItemsDto(numItemsToCreate, createdPlaylistDto.Id);

            foreach (List <PlaylistItemDto> splitPlaylistItemDtos in Split(playlistItemDtos, 50))
            {
                PlaylistItemController.CreateMultiple(splitPlaylistItemDtos);
            }

            NHibernateSessionManager.Instance.Clear();

            //  Now delete the first playlist.
            PlaylistController.Delete(firstPlaylistId);
        }