public IdentityNumberController(IDataRepository dataRepository, IIdentityNumberValidator identityNumberValidator, IIdentityNumberService identityNumberService, IHostingEnvironment environment, ILogger <IdentityNumberController> logger) { _dataRepository = dataRepository; _identityNumberValidator = identityNumberValidator; _identityNumberService = identityNumberService; _environment = environment; _logger = logger; }
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(); }
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); }
public void SetUp() { _configuration = ConfigurationSetup.SetUpConfiguration(); _identityNumberService = new TestIdentityNumberService(_configuration); _identityNumberValidator = new TestIdentityNumberValidator(_identityNumberService); }