コード例 #1
0
 public CanalController(ILoggerManager logger, ICanalService _canalService,
                        IMapper mapper, IOptions <AppSettings> appSettings)
 {
     _logger       = logger;
     _CanalService = _canalService;
     _mapper       = mapper;
     _appSettings  = appSettings.Value;
 }
コード例 #2
0
        public void Setup()
        {
            var mockMongoCollection = new Mock <IMongoCollection <Canal> >().Object;
            var canal = new Canal()
            {
                ChannelId = "SomeValue", Title = "SomeValue", Descricao = "SomeValue"
            };
            var lista = new List <Canal>()
            {
                canal
            }.AsQueryable();

            Mock <IRepository <Canal> > mock = new Mock <IRepository <Canal> >();

            mock.Setup(r => r.Table).Returns(mockMongoCollection.AsQueryable());
            mock.Setup(r => r.GetSingleAsync()).Returns(Task.FromResult(canal));

            mock.Setup(r => r.GetSingleAsync(It.IsAny <Expression <Func <Canal, bool> > >()))
            .Returns((Expression <Func <Canal, bool> > predicate) => Task.FromResult(lista.FirstOrDefault(predicate)));

            _service = new CanalService(mock.Object);
        }
コード例 #3
0
        public void Setup()
        {
            var mockCanal = new Mock <ICanalService>();

            mockCanal.Setup(x => x.GetCanalByYoutubeId(It.IsAny <string>()))
            .Returns(Task.FromResult(new Canal
            {
                Id        = "CanalIdSomeValue",
                ChannelId = "ChannelIdSomeValue",
                Title     = "TitleSomeValue",
                Descricao = "DescricaoSomeValue"
            }));

            mockCanal.Setup(x => x.GetCanalByYoutubeId(It.Is <string>(s => s == "IncorrectYoutubeChannelId")))
            .Returns(Task.FromResult(default(Canal)));

            ICanalService canalService = mockCanal.Object;

            Video video = new Video
            {
                Id        = "VideoIdSomeValue",
                VideoId   = "YoutubeVideoIdSomeValue",
                CanalId   = "CanalIdSomeValue",
                Descricao = "DescricaoSomeValue",
                Titulo    = "TituloSomeValue",
            };
            IQueryable <Video> listaVideo = new List <Video>()
            {
                video
            }.AsQueryable();

            var mockRepository = new Mock <IRepository <Video> >();

            mockRepository.Setup(r => r.GetSingleAsync(It.IsAny <Expression <Func <Video, bool> > >()))
            .Returns((Expression <Func <Video, bool> > predicate)
                     => Task.FromResult(listaVideo.FirstOrDefault(predicate)));
            _service = new VideoService(mockRepository.Object, canalService);
        }
コード例 #4
0
 public CanalController(ICanalService canalService, IVideoService videoService)
 {
     _canalService = canalService;
     _videoService = videoService;
 }
コード例 #5
0
 public VideoService(IRepository <Video> repository, ICanalService canalService)
 {
     _repository   = repository;
     _canalService = canalService;
 }
コード例 #6
0
 public YoutubeSearchController(IYouTubeService youTubeService, ICanalService canalService, IVideoService videoService)
 {
     _youTubeService = youTubeService;
     _canalService   = canalService;
     _videoService   = videoService;
 }