Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public WebSiteStatusesController(SiteMonitoringToolDbContext dbContext, IScheduleService scheduleService, IWebSiteCrawlService webSiteCrawlService)
 {
     this.dbContext           = dbContext;
     this.scheduleService     = scheduleService;
     this.webSiteCrawlService = webSiteCrawlService;
 }
Exemplo n.º 3
0
 public AccountController(SiteMonitoringToolDbContext dbContext, IConfiguration configuration)
 {
     this.dbContext     = dbContext;
     this.configuration = configuration;
 }