public bool isNegativeNumbersExistInString(IDetectDelimitersService detectDelimitersService, string numbers, string delimiters) { _detectDelimitersService = detectDelimitersService; _numbers = numbers; _delimiters = delimiters; return(GetNegativeNumbers().Any()); }
public StringCalculatorMainApplication(IValidateNumberService validateNumberService, ICleanedNumberStringService cleanedNumberStringService, IDetectDelimitersService detectDelimitersService, IDetectNegativeNumbersService detectNegativeNumbersService) { _validateNumberService = validateNumberService; _cleanedNumberStringService = cleanedNumberStringService; _detectDelimitersService = detectDelimitersService; _detectNegativeNumbersService = detectNegativeNumbersService; }
public ValidatorStatus ValidateNumber(IDetectDelimitersService detectDelimitersService, IDetectNegativeNumbersService detectNegativeNumbersService, string numbers, string delimiters = null) { if (CheckNoNumbersExist(numbers)) { return(ValidatorStatus.NoNumbers); } if (CheckIfOnlyContainOneNumber(numbers)) { return(ValidatorStatus.SingleNumber); } if (IsNegative(detectNegativeNumbersService, detectDelimitersService, numbers, delimiters)) { throw new NegativeNumberException($"Error! There is a negative number"); } return(ValidatorStatus.NormalNumber); }
private bool IsNegative(IDetectNegativeNumbersService detectNegativeNumbersService, IDetectDelimitersService detectDelimitersService, string numbers, string delimiters) => detectNegativeNumbersService.isNegativeNumbersExistInString(detectDelimitersService, numbers, delimiters) ? true : false;
public object CleanNumbersString(IDetectDelimitersService detectDelimitersService, string numbers) { Delimiters = detectDelimitersService.GetIdentifier(numbers).Aggregate("", (current, item) => current + item.ToString()); Numbers = GetNumbersAfterCleaned(numbers); return(new { Numbers, Delimiters }); }