protected AcceptanceTests() { Container = new Container(x => { x.AddRegistry(new ArticlesRegistry(new EventStoreConfiguration())); x.For <InMemoryEventStore>().Singleton(); }); Container.Inject(Substitute.For <IWebPageDownloader>()); Container.Inject(Substitute.For <IKeywordDictionary>()); Container.Inject <IEventStore>(Container.GetInstance <InMemoryEventStore>()); Container.Inject <IEventStoreExtended>(Container.GetInstance <InMemoryEventStore>()); Container.Inject <ILogger>(new EmptyLogger()); Container .GetInstance <IKeywordDictionary>() .IsValidKeyword(Arg.Any <string>()) .Returns(true); CommandDispatcher = Container.GetInstance <ICommandDispatcher>(); WebPageDownloader = Container.GetInstance <IWebPageDownloader>(); EventStore = (InMemoryEventStore)Container.GetInstance <IEventStore>(); WebPageDownloader .Download(Arg.Any <string>()) .Returns("<html></html>"); }
public async Task <Article> Build(Guid mediaId, FeedItem feedItem) { feedItem.ImageUrl ??= await _webPageDownloader.Download(feedItem.Link) .PipeAsync(_htmlParser.ExtractArticleImageUrl) .PipeAsync(imageUrl => InjectHostIfMissing(imageUrl, feedItem.Link)) .PipeAsync(UrlSanitizer.Sanitize); return(new Article(mediaId, feedItem)); }
public ArticleFactoryTests() { _webPageDownloader = Substitute.For <IWebPageDownloader>(); _webPageDownloader.Download(Arg.Any <string>()).Returns("<html></html>"); var keywordDictionary = Substitute.For <IKeywordDictionary>(); keywordDictionary.IsValidKeyword(Arg.Any <string>()).Returns(true); _articleFactory = new ArticleFactory(new HtmlParser(), _webPageDownloader, new KeywordsParser(keywordDictionary)); }
public FullAggregatorTests() { var container = ContainerBuilder.Build(new Configuration()); _eventStore = container.GetInstance <InMemoryEventStore>(); _keywordDictionary.IsValidKeyword(Arg.Any <string>()).Returns(true); _webPageDownloader.Download(Arg.Any <string>()).Returns("<html></html>"); container.Inject(_feedReader); container.Inject(_eventPositionRepository); container.Inject(_keywordDictionary); container.Inject(_webPageDownloader); container.Inject((IEventStoreExtended)_eventStore); container.Inject((IEventStore)_eventStore); container.Inject((IEventBus)_inMemoryBus); container.Inject((ILogger) new EmptyLogger()); _aggregator = container.GetInstance <Aggregator>(); }