public async Task GenerateCard(Account account, string type) { _logger.Info($"Genereated Card by name: {account.Name}"); string cardIdentifier = GenerationHelper.GenerateIdentifier(); int timeSpan = PropertyHelper.ValidSpanYears; string initialStatus = PropertyHelper.InitialStatus; int cvc2 = GenerationHelper.GenerateCvc(); if (!_cardRepository.ValidateIdentifier(cardIdentifier)) { await GenerateCard(account, type); } string bankIdentifier = _accountPropertyRepository.GetPropertyModel().BankIdentificationNumber; string industryIdentifier = _accountPropertyRepository.GetPropertyModel().MajorIndustryIdentifier; string partialCardNumber = industryIdentifier + bankIdentifier + account.Number + cardIdentifier; string checksum = GenerationHelper.GenerateChecksum(partialCardNumber); string cardNumber = partialCardNumber + checksum; Card card = new Card() { Name = type, AccountId = account.Id, IsDefault = true, UserId = account.UserId, Number = cardNumber, RegDate = DateTime.Now, ExpDate = DateTime.Now.AddYears(timeSpan), Status = initialStatus, Cvc2 = cvc2 }; await _cardRepository.InsertAsync(card); await _cardRepository.SaveAsync(); }
protected override void Given() { actualResult = GenerationHelper.GenerateCvc().ToString(); isValid = actualResult.Length == 3; }