public HomeController(IMusicAlbumRepository musicAlbumRepository) { _musicAlbumRepository = musicAlbumRepository; }
public MusicAlbumController(IMusicAlbumRepository musicAlbumRepository, ICategoryRepository categoryRepository) { _musicAlbumRepository = musicAlbumRepository; _categoryRepository = categoryRepository; }
public void Setup() { //Repositories var albumsRepository = new Mock <IMusicAlbumRepository>(); List <DataEntities.Models.Album> listAlbums = new List <DataEntities.Models.Album>() { new DataEntities.Models.Album() { Id = 1, AlbumName = "Super Spears", Artist = "Mike", Label = "Virgin", LabelType = DataEntities.Models.LabelType.CD, Stock = 10 }, new DataEntities.Models.Album() { Id = 2, AlbumName = "Super Spears", Artist = "Mike", Label = "Virgin", LabelType = DataEntities.Models.LabelType.CD, Stock = 10 } }; albumsRepository.Setup(x => x.GetAllMusicAlbum()).Returns(listAlbums); albumsRepository.Setup(x => x.GetMusicAlbum(1)).Returns(listAlbums.Single(a => a.Id == 1)); albumsRepository.Setup(x => x.AddMusicAlbum(It.IsAny <DataEntities.Models.Album>())).Returns( (DataEntities.Models.Album target) => { listAlbums.Add(target); return(true); }); albumsRepository.Setup(x => x.UpdateMusicAlbum(It.IsAny <DataEntities.Models.Album>())).Returns( (DataEntities.Models.Album target) => { var original = listAlbums.Single(item => item.Id == target.Id); if (original == null) { return(false); } original.AlbumName = target.AlbumName; original.Artist = target.Artist; original.Label = target.Label; original.LabelType = target.LabelType; original.Stock = target.Stock; return(true); }); albumsRepository.Setup(x => x.DeleteMusicAlbum(It.IsAny <int>())).Returns( (int target) => { var original = listAlbums.Single(item => item.Id == target); listAlbums.Remove(original); return(true); }); this.AlbumsRepository = albumsRepository.Object; }
public ShoppingCartController(IMusicAlbumRepository musicAlbumRepository, ShoppingCart shoppingCart) { _musicAlbumRepository = musicAlbumRepository; _shoppingCart = shoppingCart; }
public MusicAlbumService(IMusicAlbumRepository repository) { albumRepository = repository; }