public void GetSharedPlaylist_PlaylistShareCodeExists_CopyOfPlaylistCreated() { User user = Helpers.CreateUser(); Playlist playlist = PlaylistManager.CopyAndSave(user.Playlists.First().Id); ShareCode shareCode = ShareCodeManager.GetShareCode(playlist); CopyPlaylistRequestDto shareCodeRequestDto = new CopyPlaylistRequestDto(user.Id, shareCode.EntityId); // Create a new playlist for the given user by loading up the playlist via sharecode. var playlistDto = PlaylistController.Copy(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); }