private Album CreateAlbumWithMockFile( AlbumRepository repo, HttpServerUtilityBase server, Mock<HttpPostedFileBase> mock )
        {
            Album album = repo.CreateAlbum( new BackOffice.Model.Album
            {
                Duration = TimeSpan.FromHours( 2 ),
                Title = RandomName(),
                Artist = new BackOffice.Model.Artist { Name = RandomName() },
                ReleaseDate = DateTime.UtcNow,
                Type = "Hip-Hop US",
                Tracks = new List<Track>
                            {
                                new Track
                                {
                                    Number = 1,
                                    Duration = TimeSpan.FromMinutes(4),
                                    File = mock.Object,
                                    Song = new Song
                                    {
                                        Name = RandomName(),
                                        Composed = new DateTime(2010,1,12)
                                    }
                                }
                            }
            }, server );

            return album;
        }
示例#2
0
        public ActionResult Create(Nwd.BackOffice.Model.Album album)
        {
            if (ModelState.IsValid && album.Tracks != null)
            {
                var tracks = album.Tracks;
                AlbumRepository repository = new AlbumRepository();

                repository.CreateAlbum(album, HttpContext.Server);

            }
            return View();
        }
示例#3
0
        public ActionResult Edit(Nwd.BackOffice.Model.Album album)
        {
            AlbumRepository albumRepository = new AlbumRepository();

            if (ModelState.IsValid)
            {
                albumRepository.EditAlbum(HttpContext.Server, album);
                return RedirectToRoute("list");
            }
            else
            {
                return View(album);
            }
        }
示例#4
0
 public ActionResult Edit(int id)
 {
     throw new Exception("dd");
     AlbumRepository albumRepository = new AlbumRepository();
     var albumToEdit = albumRepository.GetAllAlbums().FirstOrDefault(x => x.Id == id);
     if (albumToEdit != null)
     {
         return View(albumToEdit);
     }
     else
     {
         return HttpNotFound();
     }
 }
示例#5
0
 public ActionResult Delete(int id)
 {
     AlbumRepository albumRepository = new AlbumRepository();
     var albumToDelete = albumRepository.GetAllAlbums().FirstOrDefault(x => x.Id == id);
     if (albumToDelete != null)
     {
         albumRepository.DeleteAlbum(albumToDelete);
         return Redirect("/Admin/Album/List");
     }
     else
     {
         return HttpNotFound();
     }
 }
        public void Create_Album_With_No_Tracks()
        {
            AlbumRepository repo = new AlbumRepository();
            HttpServerUtilityBase server =  Mock.Of<HttpServerUtilityBase>();

            Album album = repo.CreateAlbum( new BackOffice.Model.Album
            {
                Duration = TimeSpan.FromHours( 2 ),
                Title = RandomName(),
                Artist = new BackOffice.Model.Artist { Name = RandomName() },
                ReleaseDate = DateTime.UtcNow,
                Type = "Pop-Rock"
            }, server );

            Assert.That( album.Id, Is.GreaterThan( 0 ) );
        }
        public void Create_Album_With_Tracks()
        {
            AlbumRepository repo = new AlbumRepository();
            HttpServerUtilityBase server =  Mock.Of<HttpServerUtilityBase>();

            var mock = new Mock<HttpPostedFileBase>();

            Assert.Throws<ApplicationException>( () =>
                {
                    CreateAlbumWithMockFile( repo, server, mock );
                }, "The file must be an .mp3 file" );

            mock.SetupGet( x => x.FileName ).Returns( RandomName() + ".mp3" );

               Album album = CreateAlbumWithMockFile( repo, server, mock );
               Assert.That( album.Id, Is.GreaterThan( 0 ) );
        }
示例#8
0
 public ActionResult List()
 {
     AlbumRepository albumRepository = new AlbumRepository();
     List<Nwd.BackOffice.Model.Album> listAlbums = albumRepository.GetAllAlbums();
     return View(listAlbums);
 }
示例#9
0
 public TrackController()
 {
     _repo = new AlbumRepository();
 }
示例#10
0
 public AlbumController()
 {
     _repo = new AlbumRepository();
 }