Пример #1
0
 public MediaListPopulating(IConfiguration configuration, IMemoryCache cache)
 {
     _configuration       = configuration;
     _cache               = cache;
     _movieRepository     = new MovieRepository(configuration, cache);
     _relationRepository  = new RelationRepository(configuration, _cache);
     _mediaListRepository = new MediaListRepository(configuration, _cache);
     _tvShowRepository    = new TVShowRepository(configuration, _cache);
 }
Пример #2
0
        public void RepositoryReturnCastInOrderDescendingTest()
        {
            List <Cast> itemsCast = new List <Cast> {
                new Cast()
                {
                    ID = 1, Name = "Name1", Birthday = DateTime.Now.AddYears(-10), TVShowId = 1
                },
                new Cast()
                {
                    ID = 2, Name = "Name2", Birthday = DateTime.Now.AddYears(-20), TVShowId = 2
                },
                new Cast()
                {
                    ID = 3, Name = "Name3", Birthday = DateTime.Now.AddYears(-30), TVShowId = 1
                },
                new Cast()
                {
                    ID = 4, Name = "Name4", Birthday = DateTime.Now.AddYears(-40), TVShowId = 2
                },
            };


            List <TVShow> itemsTVShow = new List <TVShow> {
                new TVShow()
                {
                    ID = 2, Name = "TVShow2", Cast = itemsCast.Where(c => c.TVShowId == 2).ToList()
                },
                new TVShow()
                {
                    ID = 1, Name = "TVShow1", Cast = itemsCast.Where(c => c.TVShowId == 1).ToList()
                },
            };

            var mockRepo = new Mock <ITVMazeQuery>();

            mockRepo.Setup(repo => repo.GetTVShows()).Returns(itemsTVShow);

            // Arrange
            var repositoryTVShow = new TVShowRepository(mockRepo.Object);

            // Act
            var resultTVShow = repositoryTVShow.Get().ToList();

            // Assert;
            Assert.Equal(2, resultTVShow.Count);
            Assert.Equal("Name1", resultTVShow[0].Cast.ToList()[0].Name);
            Assert.Equal("Name2", resultTVShow[1].Cast.ToList()[0].Name);
        }
Пример #3
0
        public UnitOfWork(ClamUserAccountContext context, IMapper mapper, UserManager <ClamUserAccountRegister> userManager,
                          SignInManager <ClamUserAccountRegister> signInManager, RoleManager <ClamRoles> roleManager,
                          IConfiguration config)
        {
            _context       = context;
            _userManager   = userManager;
            _signInManager = signInManager;
            _roleManager   = roleManager;
            _config        = config;
            _mapper        = mapper;

            // Instantiate Repositories with their respective dependencies
            UserAccount     = new UserAccountRepository(_context, _mapper, _userManager, _signInManager, _roleManager);
            RoleAccount     = new RoleAccountRepository(_context, _mapper, _userManager, _signInManager, _roleManager);
            EBooksControl   = new EBooksRepository(_context, _userManager, _mapper);
            MusicControl    = new MusicRepository(_context, _userManager, _mapper);
            FilmControl     = new FilmRepository(_context, _userManager, _mapper, _config);
            StorageControl  = new StorageRepository(_context, _userManager, _config, _mapper);
            AcademiaControl = new AcademiaRepository(_context, _userManager, _mapper, _config);
            TVShowControl   = new TVShowRepository(_context, _userManager, _mapper, _config);
            TicketControl   = new TicketRepository(_context, _userManager, _mapper);
            ProjectControl  = new ProjectsRepository(_context, _userManager, _mapper, _config);
        }
        public async Task GetListableItems(MediaList mediaList)
        {
            var relationRepository = new RelationRepository(Configuration, MemoryCache);

            var relList = await relationRepository.GetRelationsByParent(
                mediaList.GetEntityCategoryId(), mediaList.GetId());

            //TODO FIX!!!!
            var movieRepository  = new MovieRepository(Configuration, MemoryCache);
            var tvShowRepository = new TVShowRepository(Configuration, MemoryCache);

            foreach (var relation in relList)
            {
                if (relation.CategoryTo == Movie.ENTITY_CATEGORY_ID)
                {
                    mediaList.AddListableItem(await movieRepository.GetById(relation.EntityTo));
                }
                else if (relation.CategoryTo == TVShow.ENTITY_CATEGORY_ID)
                {
                    mediaList.AddListableItem(await tvShowRepository.GetById(relation.EntityTo));
                }
            }
        }