Пример #1
0
 public HomeController(IMusicAlbumRepository musicAlbumRepository)
 {
     _musicAlbumRepository = musicAlbumRepository;
 }
 public MusicAlbumController(IMusicAlbumRepository musicAlbumRepository, ICategoryRepository categoryRepository)
 {
     _musicAlbumRepository = musicAlbumRepository;
     _categoryRepository   = categoryRepository;
 }
Пример #3
0
        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;
 }
Пример #5
0
 public MusicAlbumService(IMusicAlbumRepository repository)
 {
     albumRepository = repository;
 }