public async Task <FixActionLogger> DoAsync(CancellationToken cancellationToken, string lognameSuffix) { var logger = new FixActionLogger(); logger.Start(); try { var tasks = new[] { _scanner.ScanForDiscrepanciesAsync(_integrityCheckConfiguration, logger, cancellationToken), _fixer.FixDiscrepanciesAsync(logger, cancellationToken) }; await Task.WhenAll(tasks); } catch (Exception ex) { logger.TerminalException = $"{ex.GetType().Name} - {ex.Message}"; throw; } finally { logger.Finish(); await SaveFixLoggerResults(logger, lognameSuffix); } return(logger); }
private void CheckPropertyPostFinish(Action <FixActionLogger> assert, Action <FixActionLogger> setup = null) { var logger = new FixActionLogger(); logger.Start(); setup?.Invoke(logger); logger.Finish(); assert(logger); }
private static FixActionLoggerItem CreateLogItem(FixActionLogger logger, ActivityDiscrepancyType discrepancyType) { var newItem = new FixActionLoggerItem { Discrepancy = discrepancyType }; logger.Add(newItem); return(newItem); }
private static FixActionLogger AddFixer <TFixerType>(this FixActionLogger logger, ActivityDiscrepancyType discrepancyType, int instances, string error) where TFixerType : IActivityDiscrepancyFixer, new() { for (int i = 0; i < instances; i++) { var item = CreateLogItem(logger, discrepancyType); item.Add(new FixActionHandlerLoggerItem(new TFixerType()) { Error = error, FixMSecs = 1 }); } return(logger); }
private void AssertFixerSummaryIsCorrect <TFixerType>(FixActionLogger logger, int expectedNumberOfFailures, int expectedNumberOfSuccesses) where TFixerType : IActivityDiscrepancyFixer { var handlerSummary = logger.HandlerSummary.SingleOrDefault(hs => hs.Handler == typeof(TFixerType).FullName); if (handlerSummary == null) { if (expectedNumberOfFailures == 0 && expectedNumberOfSuccesses == 0) { return; } Assert.Fail($"A handler summary for {typeof(TFixerType).Name} has not been created when {expectedNumberOfFailures} failures and {expectedNumberOfSuccesses} successes were expected"); } Assert.AreEqual(expectedNumberOfFailures, handlerSummary.Fail); Assert.AreEqual(expectedNumberOfSuccesses, handlerSummary.Success); Assert.AreEqual(expectedNumberOfFailures + expectedNumberOfSuccesses, handlerSummary.Occurrences); Assert.AreEqual(expectedNumberOfFailures + expectedNumberOfSuccesses, handlerSummary.ExecutionTime); }
private Task SaveFixLoggerResults(FixActionLogger logger, string lognameSuffix) { return(_blobRepo.SerialiseObjectToLog($"IntegrityCheckResults_{lognameSuffix}", logger)); }
public static FixActionLogger AddSuccessFixer2(this FixActionLogger logger, ActivityDiscrepancyType discrepancyType, int instances = 1) { return(logger.AddFixer <TestFixer2>(discrepancyType, instances, null)); }
public static FixActionLogger AddFailedFixer2(this FixActionLogger logger, ActivityDiscrepancyType discrepancyType, int instances = 1, string error = "Test Error") { return(logger.AddFixer <TestFixer2>(discrepancyType, instances, error)); }