public void Test_DataCollector_FakeReader() { var dc = new DataCollector(new FakeReader()); var result = dc.Collect(string.Empty); Assert.NotNull(result); Assert.Equal(7, result.Count); }
static void Main(string[] args) { var parameterParser = new ParameterParser(); var parameters = parameterParser.ParseParameters(args); if (parameters == null) { WriteUsage(); return; } try { List <Lender> lenders = null; using (IReader reader = new CsvReader()) { var collector = new DataCollector(reader); lenders = collector.Collect(parameters.FileName); } var loanCalculator = new LoanCalculator(); var result = loanCalculator.CalculateLoan(lenders, parameters.TargetAmount, 3); if (result == null) { Console.WriteLine("It's not possible to provide a quote"); } else { PrintLending(result); } } catch (ReaderException rEx) { Console.WriteLine("Error during reading input: {0}", rEx.Message); } catch (DataParsingException dpEx) { Console.WriteLine("Error during parsing data: {0}", dpEx.Message); } catch (CalculatorException cEx) { Console.WriteLine("Error during calculation: {0}", cEx.Message); } catch (Exception ex) { Console.WriteLine("Uncategorized error: {0}", ex.Message); } }
/// <summary> /// Backup web service data to database /// </summary> /// <param name="context"></param> public void Execute(IJobExecutionContext context) { log.Info("Execute task: data collection..."); if (!_cfgCollectData) { log.Info("Data collection not enabled"); return; } try { DataCollector.Collect(); } catch (Exception ex) { log.ErrorFormat("job failed: {0}", ex); } log.Info("Execute task: data cleanup..."); if (!_cfgRunCleanup) { log.Info("Data cleanup not enabled"); return; } try { DataCleaner.DoCleanup(); } catch (Exception ex) { log.ErrorFormat("job failed: {0}", ex); } }