示例#1
0
        public void UpdatePlaylistEntityAlreadyExist()
        {
            Playlist newPlaylist = new Playlist()
            {
                Id               = 1,
                Name             = "",
                Description      = "Old hits",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };
            PlaylistCategory play = new PlaylistCategory
            {
                IdCategory = 1,
            };
            PlaylistCategory play2 = new PlaylistCategory
            {
                IdCategory = 1,
            };

            playlistList[0].PlaylistCategory.Add(play);
            newPlaylist.PlaylistCategory.Add(play);
            newPlaylist.PlaylistCategory.Add(play2);
            var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict);

            mockPlaylist.Setup(l => l.Get(playlistList[0].Id)).Returns(playlistList[0]);
            mockPlaylist.Setup(l => l.Update(playlistList[0], 1)).Throws(new EntityAlreadyExist("There are two or more equal categories"));
            var controller = new PlaylistController(mockPlaylist.Object);
            var result     = controller.UpdatePlaylist(1, newPlaylist);

            Mock.VerifyAll();
            Assert.AreEqual(new UnprocessableEntityObjectResult("").ToString(),
                            result.ToString());
        }
        public void AddPlaylistOk()
        {
            Playlist playlistToAdd = new Playlist()
            {
                Id               = 1,
                Name             = "Baile",
                Description      = "Lo mejor 2021",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };

            PlaylistCategory playlistCategory = new PlaylistCategory
            {
                Category = new Category
                {
                    Id               = 1,
                    Name             = "Dormir",
                    CategoryTrack    = new List <CategoryTrack>(),
                    PlaylistCategory = new List <PlaylistCategory>()
                },
                IdCategory = 1,
                IdPlaylist = 1,
                Playlist   = playlistToAdd
            };

            playlistToAdd.PlaylistCategory.Add(playlistCategory);
            playlistToAdd.PlaylistVideo = new List <PlaylistVideo>();
            playlistToAdd.PlaylistTrack = new List <PlaylistTrack>();
            playlistLogic.Add(playlistToAdd);
        }
示例#3
0
        public void UpdatePlaylistEntityNotExist()
        {
            Playlist newPlaylist = new Playlist()
            {
                Id               = 1,
                Name             = "",
                Description      = "Old hits",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };
            PlaylistCategory play = new PlaylistCategory
            {
                IdCategory = 100,
            };

            playlistList[0].PlaylistCategory.Add(play);
            newPlaylist.PlaylistCategory.Add(play);
            var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict);

            mockPlaylist.Setup(l => l.Get(playlistList[0].Id)).Returns(playlistList[0]);
            mockPlaylist.Setup(l => l.Update(playlistList[0], 1)).Throws(new EntityNotExists("One ore more category do not exist"));
            var controller = new PlaylistController(mockPlaylist.Object);
            var result     = controller.UpdatePlaylist(1, newPlaylist);

            Mock.VerifyAll();
            Assert.AreEqual(new NotFoundObjectResult("").ToString(),
                            result.ToString());
        }
        public void AddPlaylistDescriptionLengthWrong()
        {
            Playlist playlistToAdd = new Playlist()
            {
                Id          = 1,
                Name        = "Variado",
                Description = "Lo mejor 2021 del mundo mundial mundoooooooooooooooooooooooooooo ksdksdsd   sdsd sd s ds d sd   sd sdsdsd sd sd sd  ds d" +
                              " sdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsds sdsds sdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsd",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };

            PlaylistCategory playlistCategory = new PlaylistCategory
            {
                Category = new Category
                {
                    Id               = 1,
                    Name             = "Dormir",
                    CategoryTrack    = new List <CategoryTrack>(),
                    PlaylistCategory = new List <PlaylistCategory>()
                },
                IdCategory = 1,
                IdPlaylist = 1,
                Playlist   = playlistToAdd
            };

            playlistToAdd.PlaylistCategory.Add(playlistCategory);
            Assert.ThrowsException <FieldEnteredNotCorrect>(() => playlistLogic.Add(playlistToAdd));
        }
        public void AddPlaylistNameEmpty()
        {
            Playlist playlistToAdd = new Playlist()
            {
                Id               = 1,
                Name             = "",
                Description      = "Lo mejor 2021",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };

            PlaylistCategory playlistCategory = new PlaylistCategory
            {
                Category = new Category
                {
                    Id               = 1,
                    Name             = "Dormir",
                    CategoryTrack    = new List <CategoryTrack>(),
                    PlaylistCategory = new List <PlaylistCategory>()
                },
                IdCategory = 1,
                IdPlaylist = 1,
                Playlist   = playlistToAdd
            };

            playlistToAdd.PlaylistCategory.Add(playlistCategory);
            Assert.ThrowsException <FieldEnteredNotCorrect>(() => playlistLogic.Add(playlistToAdd));
        }
        public void Initialize()
        {
            playlist = new Playlist
            {
                Id               = 1,
                Name             = "Musica para Mauro",
                Description      = "De todo",
                PlaylistCategory = new List <PlaylistCategory>()
            };

            category = new Category
            {
                Name             = "Dormir",
                Id               = 1,
                CategoryTrack    = new List <CategoryTrack>(),
                CategoryVideo    = new List <CategoryVideo>(),
                PlaylistCategory = new List <PlaylistCategory>()
            };
            track = new Track
            {
                Id     = 1,
                Image  = "",
                Author = "",
                Name   = "Mauro baila cumbia"
            };

            video = new Video
            {
                Id        = 1,
                Author    = "Rodrigo",
                LinkVideo = "www.youtube.com/baile",
                Name      = "Baile",
                Hour      = 1
            };
            categoryTrack = new CategoryTrack
            {
                IdCategory = category.Id,
                Category   = category,
                IdTrack    = track.Id,
                Track      = track,
            };
            categoryVideo = new CategoryVideo
            {
                IdCategory = category.Id,
                Category   = category,
                IdVideo    = video.Id,
                Video      = video,
            };
            playlistCategory = new PlaylistCategory
            {
                IdCategory = category.Id,
                Category   = category,
                IdPlaylist = playlist.Id,
                Playlist   = playlist
            };
            category.CategoryVideo.Add(categoryVideo);
            category.CategoryTrack.Add(categoryTrack);
            category.PlaylistCategory.Add(playlistCategory);
        }
 public void Initialize()
 {
     playlistCategory = new PlaylistCategory();
     playlist         = new Playlist
     {
         Name          = "Cumbia",
         Id            = 1,
         Description   = "Boliche",
         Image         = "",
         PlaylistTrack = new List <PlaylistTrack>()
     };
     category = new Category
     {
         Name          = "Dormir",
         Id            = 2,
         CategoryTrack = new List <CategoryTrack>()
     };
 }
        public void AddPlaylistValidateCategoryUnique()
        {
            Playlist playlistToAdd = new Playlist()
            {
                Id               = 1,
                Name             = "New music",
                Description      = "Lo mejor 2021",
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistTrack    = new List <PlaylistTrack>()
            };

            PlaylistCategory playlistCategory = new PlaylistCategory
            {
                Category = new Category
                {
                    Id               = 1,
                    Name             = "Dormir",
                    CategoryTrack    = new List <CategoryTrack>(),
                    PlaylistCategory = new List <PlaylistCategory>()
                },
                IdCategory = 1,
                IdPlaylist = 1,
                Playlist   = playlistToAdd
            };
            PlaylistCategory playlistCategory2 = new PlaylistCategory
            {
                Category = new Category
                {
                    Id               = 1,
                    Name             = "Dormir",
                    CategoryTrack    = new List <CategoryTrack>(),
                    PlaylistCategory = new List <PlaylistCategory>()
                },
                IdCategory = 1,
                IdPlaylist = 1,
                Playlist   = playlistToAdd
            };

            playlistToAdd.PlaylistCategory.Add(playlistCategory);
            playlistToAdd.PlaylistCategory.Add(playlistCategory2);
            Assert.ThrowsException <EntityAlreadyExist>(() => playlistLogic.Add(playlistToAdd));
        }
示例#9
0
        public void AddPlaylistErrorCategoryUnique()
        {
            List <PlaylistCategory> list = new List <PlaylistCategory>();
            PlaylistCategory        play = new PlaylistCategory
            {
                IdCategory = 1
            };
            PlaylistCategory play2 = new PlaylistCategory
            {
                IdCategory = 1
            };

            list.Add(play);
            list.Add(play2);
            playlistList[0].PlaylistCategory = list;
            var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict);

            mockPlaylist.Setup(r => r.Add(playlistList[0])).Throws(new EntityAlreadyExist(""));
            PlaylistController controller = new PlaylistController(mockPlaylist.Object);
            var result = controller.Add(playlistList[0]);

            Assert.AreEqual(new UnprocessableEntityObjectResult("").ToString(), result.ToString());
        }
示例#10
0
        public void Initialize()
        {
            playlist = new Playlist {
                Id               = 2,
                Name             = "Mauro",
                Description      = "Facil para dormir",
                Image            = "",
                PlaylistTrack    = new List <PlaylistTrack>(),
                PlaylistCategory = new List <PlaylistCategory>(),
                PlaylistVideo    = new List <PlaylistVideo>()
            };
            track = new Track {
                Id            = 1,
                Image         = "",
                Author        = "",
                Sound         = "",
                Name          = "Mauro baila cumbia",
                CategoryTrack = new List <CategoryTrack>(),
            };
            category = new Category
            {
                Id   = 1,
                Name = "Dormir"
            };

            playlistTrack = new PlaylistTrack
            {
                IdPlaylist = playlist.Id,
                Playlist   = playlist,
                IdTrack    = track.Id,
                Track      = track,
            };

            playlistCategory = new PlaylistCategory
            {
                IdPlaylist = playlist.Id,
                Playlist   = playlist,
                IdCategory = category.Id,
                Category   = category
            };
            video = new Video
            {
                Id            = 1,
                Name          = "Bailando",
                Author        = "Mauro",
                Hour          = 1,
                MinSeconds    = 2.10,
                LinkVideo     = "www.youtube.com/videomauro",
                CategoryVideo = new List <CategoryVideo>(),
                PlaylistVideo = new List <PlaylistVideo>()
            };
            playlistVideo = new PlaylistVideo
            {
                IdPlaylist = playlist.Id,
                Playlist   = playlist,
                IdVideo    = video.Id,
                Video      = video
            };
            playlist.PlaylistVideo.Add(playlistVideo);
            playlist.PlaylistTrack.Add(playlistTrack);
            playlist.PlaylistCategory.Add(playlistCategory);
        }