public NewsContentfulFactoryTest() { _contentfulNews = new ContentfulNewsBuilder().Document().Build(); _videoRepository = new Mock <IVideoRepository>(); _documentFactory = new Mock <IContentfulFactory <Asset, Document> >(); _alertBuilder = new Mock <IContentfulFactory <ContentfulAlert, Alert> >(); _newsContentfulFactory = new NewsContentfulFactory(_videoRepository.Object, _documentFactory.Object, _alertBuilder.Object, _timeProvider.Object); }
public NewsRepositoryTest() { _mockTimeProvider = new Mock <ITimeProvider>(); _videoRepository = new Mock <IVideoRepository>(); _cacheWrapper = new Mock <ICache>(); _newsContentType = new ContentType() { Fields = new List <Field>() { new Field() { Name = "Categories", Items = new Schema() { Validations = new List <IFieldValidator>() { new InValuesValidator { RequiredValues = new List <string>() { "Benefits", "Business", "Council leader" } } } } } } }; _newsroomContentfulCollection = new ContentfulCollection <ContentfulNewsRoom>(); _newsroomContentfulCollection.Items = new List <ContentfulNewsRoom> { new ContentfulNewsRoomBuilder().Build() }; _contentfulClientManager = new Mock <IContentfulClientManager>(); _client = new Mock <IContentfulClient>(); _contentfulClientManager.Setup(o => o.GetClient(_config)).Returns(_client.Object); _alertBuilder = new Mock <IContentfulFactory <ContentfulAlert, Alert> >(); _contentfulFactory = new NewsContentfulFactory(_videoRepository.Object, new DocumentContentfulFactory(), _alertBuilder.Object, _mockTimeProvider.Object); _client.Setup(o => o.GetEntries( It.Is <QueryBuilder <ContentfulNewsRoom> >(q => q.Build() == new QueryBuilder <ContentfulNewsRoom>().ContentTypeIs("newsroom").Include(1).Build()), It.IsAny <CancellationToken>())).ReturnsAsync(_newsroomContentfulCollection); _client.Setup(o => o.GetContentType("news", It.IsAny <CancellationToken>())) .ReturnsAsync(_newsContentType); _newsContentfulFactory = new Mock <IContentfulFactory <ContentfulNews, News> >(); _newsRoomContentfulFactory = new Mock <IContentfulFactory <ContentfulNewsRoom, Newsroom> >(); _configuration = new Mock <IConfiguration>(); _configuration.Setup(_ => _["redisExpiryTimes:News"]).Returns("60"); _repository = new NewsRepository(_config, _mockTimeProvider.Object, _contentfulClientManager.Object, _newsContentfulFactory.Object, _newsRoomContentfulFactory.Object, _cacheWrapper.Object, _configuration.Object); }