public async Task Run() { try { // Start watch var stopwatch = new Stopwatch(); stopwatch.Start(); // Get all dependencies var indicatorDependencies = await _indicatorDependencyRepository.GetAll(); // Build IndicatorDependencyBuilder.BuildLevel(indicatorDependencies); // Update _indicatorDependencyRepository.UpdateRange(indicatorDependencies); // Save await _mainDbContext.SaveChangesAsync(); // Stop watch stopwatch.Stop(); // Log into Splunk _logger.LogSplunkJob(new { MaxLevel = indicatorDependencies.Select(x => x.Level).Max(), ExecutionTime = stopwatch.Elapsed.TotalSeconds }); // Return await Task.CompletedTask; } catch (Exception ex) { // Log into Splunk _logger.LogSplunkJob(new { JobFailed = ex.Message }); // Log error into Splunk _logger.LogSplunkError(ex); } }
public void BuildDependencyLevel_1() { // Arrange var dependencyLevels = new List <IndicatorDependency> { new IndicatorDependency("2", "1", 0), new IndicatorDependency("3", "1", 0), new IndicatorDependency("3", "2", 0), new IndicatorDependency("4", "3", 0), new IndicatorDependency("5", "3", 0) }; // Act IndicatorDependencyBuilder.BuildLevel(dependencyLevels); // Assert Assert.AreEqual(true, dependencyLevels[0].Level == 1); Assert.AreEqual(true, dependencyLevels[1].Level == 1); Assert.AreEqual(true, dependencyLevels[2].Level == 2); Assert.AreEqual(true, dependencyLevels[3].Level == 3); Assert.AreEqual(true, dependencyLevels[3].Level == 3); }