public async Task <string> GenerateUniqueShortLink() { bool codeIsUnique; string shortCode; do { shortCode = _generator.GenerateShortCode(); codeIsUnique = await _repository.CheckIfShortCodeIsUniqueAsync(shortCode); } while (!codeIsUnique); return(shortCode); }
public void WhenShortCodeIsGenerated_ThenAValidShortCodeIsReturned(int length) { var shortCode = _generator.GenerateShortCode(length); Assert.IsTrue(Regex.IsMatch(shortCode, Constants.ShortCodeRegularExpression)); }