public async Task CrawlTest() { // Arrange var logger = mockRepository.Create <ILogger <WebSiteCrawlService> >(); var serviceCollection = new ServiceCollection(); var webSiteStatus = new WebSiteStatus { Id = 1, Url = "http://ya.ru" }; serviceCollection.AddScoped(typeof(SiteMonitoringToolDbContext), sp => { var options = new DbContextOptionsBuilder <SiteMonitoringToolDbContext>() .UseInMemoryDatabase(databaseName: "InMemoryDatabase") .Options; var funcResult = new SiteMonitoringToolDbContext(options); funcResult.WebSiteStatuses.Add(webSiteStatus); return(funcResult); }); var serviceProvider = serviceCollection.BuildServiceProvider(); webSiteCrawlService = new WebSiteCrawlService(logger.Object, serviceProvider); // Act await webSiteCrawlService.Crawl(webSiteStatus); // Assert Assert.AreEqual(true, webSiteStatus.IsActive); }
public WebSiteStatusesController(SiteMonitoringToolDbContext dbContext, IScheduleService scheduleService, IWebSiteCrawlService webSiteCrawlService) { this.dbContext = dbContext; this.scheduleService = scheduleService; this.webSiteCrawlService = webSiteCrawlService; }
public AccountController(SiteMonitoringToolDbContext dbContext, IConfiguration configuration) { this.dbContext = dbContext; this.configuration = configuration; }