예제 #1
0
        public async Task <string> GenerateUniqueShortLink()
        {
            bool   codeIsUnique;
            string shortCode;

            do
            {
                shortCode    = _generator.GenerateShortCode();
                codeIsUnique = await _repository.CheckIfShortCodeIsUniqueAsync(shortCode);
            } while (!codeIsUnique);

            return(shortCode);
        }
예제 #2
0
        public void WhenShortCodeIsGenerated_ThenAValidShortCodeIsReturned(int length)
        {
            var shortCode = _generator.GenerateShortCode(length);

            Assert.IsTrue(Regex.IsMatch(shortCode, Constants.ShortCodeRegularExpression));
        }