Example #1
0
 public IdentityNumberController(IDataRepository dataRepository,
                                 IIdentityNumberValidator identityNumberValidator,
                                 IIdentityNumberService identityNumberService,
                                 IHostingEnvironment environment,
                                 ILogger <IdentityNumberController> logger)
 {
     _dataRepository          = dataRepository;
     _identityNumberValidator = identityNumberValidator;
     _identityNumberService   = identityNumberService;
     _environment             = environment;
     _logger = logger;
 }
Example #2
0
        public void SetUp()
        {
            _dataRepository = new Mock <IDataRepository>();
            //_dataRepository.Setup(x => x.Save(It.IsAny<List<ValidIDInfo>>(), It.IsAny<FileCsvType>()));
            _hostingEnvironment = new Mock <IHostingEnvironment>();
            _formFile           = new Mock <IFormFile>();
            _logger             = new Mock <ILogger <IdentityNumberController> >();
            _configuration      = ConfigurationSetup.SetUpConfiguration();

            _identityNumberService    = new TestIdentityNumberService(_configuration);
            _identityNumberValidator  = new TestIdentityNumberValidator(_identityNumberService);
            _identityNumberController = new IdentityNumberController(_dataRepository.Object, _identityNumberValidator,
                                                                     _identityNumberService, _hostingEnvironment.Object, _logger.Object);
            SetUpDataRepository();
        }
Example #3
0
        public IdInfo ExtractIdInformation(string[] idNumbers, IIdentityNumberValidator identityNumberValidator)
        {
            var idInfo = new IdInfo();

            foreach (var idnum in idNumbers)
            {
                // validate the identity number
                var result = identityNumberValidator.Validate(idnum);
                if (result.Isvalid)
                {
                    ValidIDInfo validIdInfo = ExtractValidIdInformation(idnum);
                    idInfo.validIdInfos.Add(validIdInfo);
                }
                else
                {
                    var invalidIdInfo = new InvalidIDInfo(idnum, result.ErrorMessage);
                    idInfo.InvalidIdInfos.Add(invalidIdInfo);
                }
            }

            return(idInfo);
        }
Example #4
0
 public void SetUp()
 {
     _configuration           = ConfigurationSetup.SetUpConfiguration();
     _identityNumberService   = new TestIdentityNumberService(_configuration);
     _identityNumberValidator = new TestIdentityNumberValidator(_identityNumberService);
 }