public NewsService(DataContext context, IUnitOfWork unitOfWork, INewsRater newsRater, IRssLoader rssLoader, INewsParser newsParser) { _context = context; _unitOfWork = unitOfWork; _rssLoader = rssLoader; _newsParser = newsParser; _newsRater = newsRater; }
public async Task InitializeAsync() { var html = await File.ReadAllTextAsync("./hackernewsHtml.html"); var context = BrowsingContext.New(Configuration.Default); document = await context.OpenAsync(req => req.Content(html)); pageLoader = NSubstitute.Substitute.For <IAngleSharpPageLoader>(); pageLoader.LoadPage(Arg.Any <string>()).Returns(document); hackerNewsFieldsParser = Substitute.For <INewsParser>(); hackerNewsFieldsParser.ParseTitle(Arg.Any <string>()).Returns("Title"); hackerNewsFieldsParser.ParseUser(Arg.Any <string>()).Returns("User"); hackerNewsFieldsParser.TryParseUrl(Arg.Any <string>(), out Arg.Any <Uri>()) .Returns(x => { x[1] = new Uri("http://test.com"); return(true); }); hackerNewsFieldsParser.TryParsePoints(Arg.Any <string>(), out Arg.Any <int>()) .Returns(x => { x[1] = 10; return(true); }); hackerNewsFieldsParser.TryParseRank(Arg.Any <string>(), out Arg.Any <int>()) .Returns(x => { x[1] = 20; return(true); }); hackerNewsFieldsParser.TryParseComments(Arg.Any <string>(), out Arg.Any <int>()) .Returns(x => { x[1] = 30; return(true); }); documentParser = new HackerNewsHtmlDocumentParser(hackerNewsFieldsParser); }
public HackerNewsHtmlDocumentParser(INewsParser newsFieldsParser) { this.newsFieldsParser = newsFieldsParser; }
public RSSReader(INewsParser newsParser, IMapping newsMapping) { this._newsParser = newsParser; this._newsMapping = newsMapping; }