public IValidationResult Validate(IExcelParser excelParser)
        {
            if (excelParser == null) throw new ArgumentNullException("excelParser");

            var result = new ValidationResult {ValidationTarget = excelParser};

            try
            {
                foreach (var ruleResult in _rules.Select(r => r.Check(excelParser)))
                {
                    result.Messages.Add(ruleResult.Message);
                    if (!ruleResult.ShouldContinue)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                var error = e.ToString().ToValidationError();
                result.Messages.Add(error);
            }

            return result;
        }
 public virtual IValidationRuleResult Check(IExcelParser excelParser)
 {
     var shouldContinue = true;
     Action next = () => { shouldContinue = true; };
     IValidationMessage message;
     Validate(excelParser, out message, next);
     return new ValidationRuleResult {Message = message, ShouldContinue = shouldContinue};
 }
 public ImportPollingStationsCommandsHandler(
     VotRomaniaContext context,
     IImportJobsRepository importJobsRepository,
     IPollingStationsRepository pollingStationsRepository,
     IImportedPollingStationsRepository importedPollingStationsRepository,
     IBackgroundJobsQueue backgroundJobsQueue,
     IPollingStationSearchService pollingStationSearchService,
     IExcelParser excelParser,
     ILogger <ImportPollingStationsCommandsHandler> logger)
 {
     _context = context;
     _importJobsRepository              = importJobsRepository;
     _pollingStationsRepository         = pollingStationsRepository;
     _importedPollingStationsRepository = importedPollingStationsRepository;
     _backgroundJobsQueue         = backgroundJobsQueue;
     _pollingStationSearchService = pollingStationSearchService;
     _excelParser = excelParser;
     _logger      = logger;
 }
 protected abstract void Validate(IExcelParser blockPlan, out IValidationMessage message, Action next);
Exemplo n.º 5
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="excelParser"></param>
 /// <param name="contactService"></param>
 public ContactsController(IExcelParser <ContactModel> excelParser, IContactService contactService)
 {
     _excelParser    = excelParser;
     _contactService = contactService;
 }
Exemplo n.º 6
0
 public void Teardown()
 {
     _contactParser  = null;
     _contactService = null;
 }
Exemplo n.º 7
0
 public void Setup()
 {
     _contacts       = SetUpContacts();
     _contactParser  = new ContactParser();
     _contactService = SetUpContactService();
 }
Exemplo n.º 8
0
 public ParserController(IExcelParser excelParser)
 {
     _parser = excelParser;
 }
Exemplo n.º 9
0
 public ExcelUploader(IExcelParser excelParser)
 {
     this.excelParser = excelParser;
 }
        protected void SetUp()
        {
            this.excelParser = MockRepository.GenerateStub <IExcelParser>();

            this.excelUploader = new ExcelUploader(excelParser);
        }
 protected override void Validate(IExcelParser blockPlan, out IValidationMessage message, Action next)
 {
     Validate(blockPlan, out message, _localization, next);
 }