public async Task FullSearchTest() { //Arrange var retrievers = new List <IRetriever>() { new GoogleRetriever(Config, new Mock <ILogger <GoogleRetriever> >().Object), new DuckDuckGoRetriever(Config, new Mock <ILogger <DuckDuckGoRetriever> >().Object), new BingRetriever(Config, new Mock <ILogger <BingRetriever> >().Object) }; var scrapers = new List <IScraper>() { new GoogleScraper(new Mock <ILogger <GoogleScraper> >().Object), new DuckDuckGoScraper(new Mock <ILogger <DuckDuckGoScraper> >().Object), new BingScraper(new Mock <ILogger <BingScraper> >().Object) }; var aggregatorService = new AggregatorService(); var searchService = new SearchService(retrievers, scrapers, aggregatorService, Config, new Mock <ILogger <SearchService> >().Object); //Act var results = await searchService.Search("tesla"); //Assert Assert.IsTrue(results.Count() > 0); }
public IMouseProcessor GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) { ITagAggregator <ErrorGlyphTag> tagAggregator = AggregatorService.CreateTagAggregator <ErrorGlyphTag>(wpfTextViewHost.TextView.TextBuffer); IToolTipProvider tooltipProvider = ToolTipProviderFactory.GetToolTipProvider(wpfTextViewHost.TextView); return(new ErrorGlyphMouseProcessor(wpfTextViewHost, margin, tagAggregator, tooltipProvider)); }
//[Ignore("Used for dev only")] public void Aggregate_Ok() { // Arrange var aggregatorService = new AggregatorService(UnitTestLoggerFactory, ConfigurationService, _ftpService, _firestoreService, _storageService, _igcReaderService, _netcoupeServiceMock.Object); // Act aggregatorService.RunAsync(); // Assert Check.That(true); }
public async void PriorityProviderWithExtraPrice(int extraPricePercent) { var config = new Dictionary <string, string> { { "Aggregator:PriorityProvider:Name", "Tui" }, { "Aggregator:PriorityProvider:ExtraPricePercent", extraPricePercent.ToString() }, }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(config) .Build(); var country = new Country(1, "Russia"); var city = new City(1, country, "Moscow"); var hotel = new Hotel(Guid.NewGuid(), "Hilton", "Lenina, 1", city, 2019); var lowExtraPrice = 4m; var tour_other_lowExtraPrice = new Tour(Guid.NewGuid(), "Other", hotel, "luxe", city, DateTime.Today, DateTime.Today.AddDays(10), DateTime.Today, 10, 100.0m, 100.0m, "S7", 2); var tour_tui_lowExtraPrice = tour_other_lowExtraPrice.With(provider: "Tui", fullPrice: tour_other_lowExtraPrice.FullPrice * (1 + 0.01m * lowExtraPrice)); var highExtraPrice = 10m; var tour_other_highExtraPrice = new Tour(Guid.NewGuid(), "Other", hotel, "deluxe", city, DateTime.Today, DateTime.Today.AddDays(10), DateTime.Today, 10, 100.0m, 100.0m, "S7", 2); var tour_tui_highExtraPrice = tour_other_highExtraPrice.With(provider: "Tui", fullPrice: tour_other_highExtraPrice.FullPrice * (1 + 0.01m * highExtraPrice)); var searcher1 = new Mock <ISearchService>(); searcher1.Setup(mock => mock.Search(null, null, null, It.IsAny <CancellationToken>())) .ReturnsAsync(new[] { tour_other_lowExtraPrice, tour_other_highExtraPrice }); var searcher2 = new Mock <ISearchService>(); searcher2.Setup(mock => mock.Search(null, null, null, It.IsAny <CancellationToken>())) .ReturnsAsync(new[] { tour_tui_lowExtraPrice, tour_tui_highExtraPrice }); var aggregator = new AggregatorService(new[] { searcher1.Object, searcher2.Object }, configuration); var result = await aggregator.Search(null, null, null); Assert.Equal(new[] { lowExtraPrice < extraPricePercent ? tour_tui_lowExtraPrice : tour_other_lowExtraPrice, highExtraPrice < extraPricePercent ? tour_tui_highExtraPrice : tour_other_highExtraPrice }, result); }
public async Task <dynamic> PostAsync([FromBody] ServerSelection value) { IPAddress ip; var address = Dns.GetHostAddresses(value.Ip).FirstOrDefault().ToString(); bool valid = IPAddress.TryParse(address, out ip); if (valid) { AggregatorService service = new AggregatorService(HttpHelper.client); ServerSelection server = value; server.Ip = ip.ToString(); dynamic results = await service.GetAllIpInfo(server); return(Ok(results)); } else { return(BadRequest()); } }
public async void IgnoreSlowSearcher() { var config = new Dictionary <string, string> { { "Aggregator:Search:Timeout", "0.3" }, }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(config) .Build(); var country = new Country(1, "Russia"); var city = new City(1, country, "Moscow"); var hotel = new Hotel(Guid.NewGuid(), "Hilton", "Lenina, 1", city, 2019); var tour1 = new Tour(Guid.NewGuid(), "Tui", hotel, "luxe", city, DateTime.Today, DateTime.Today.AddDays(10), DateTime.Today, 10, 100.0m, 100.0m, "S7", 2); var tour2 = new Tour(Guid.NewGuid(), "Tui", hotel, "deluxe", city, DateTime.Today, DateTime.Today.AddDays(10), DateTime.Today, 10, 100.0m, 100.0m, "S7", 2); var searcher1 = new Mock <ISearchService>(); searcher1.Setup(mock => mock.Search(null, null, null, It.IsAny <CancellationToken>())) .ReturnsAsync(new[] { tour1 }, TimeSpan.FromSeconds(0.25)); var searcher2 = new Mock <ISearchService>(); searcher2.Setup(mock => mock.Search(null, null, null, It.IsAny <CancellationToken>())) .ReturnsAsync(new[] { tour1, tour2 }, TimeSpan.FromSeconds(0.25)); var slowSearcher1 = new Mock <ISearchService>(); slowSearcher1.Setup(mock => mock.Search(null, null, null, It.IsAny <CancellationToken>())) .ReturnsAsync(new[] { tour1, tour2 }, TimeSpan.FromSeconds(3)); var aggregator = new AggregatorService(new[] { searcher1.Object, searcher2.Object, slowSearcher1.Object }, configuration); var watch = new Stopwatch(); watch.Start(); var result = await aggregator.Search(null, null, null); Assert.Equal(new[] { tour1, tour2 }, result); Assert.InRange(watch.Elapsed.TotalSeconds, 0.3, 0.4); }
public SearchController(AggregatorService searchService) { this.searchService = searchService; }
public AggregatorServiceTest() { _aggregatrService = new AggregatorService(); }