Beispiel #1
0
        public ShortUrlResult GetByAlias(string aliasName)
        {
            ShortUrlResult result = Validation.Validate <ShortUrlResult>(() => string.IsNullOrWhiteSpace(aliasName), "alias", TextMessages.AliasCannotBeBlank)
                                    .Or(() => !baseX.IsValid(aliasName), "alias", TextMessages.AliasIsNotValidAliasCanOnlyContainAlphanumericCharacters)
                                    .Result();

            if (result.RuleViolations.IsEmpty())
            {
                Alias alias = GetAlias(aliasName, out result);

                if (result.RuleViolations.IsEmpty())
                {
                    result = new ShortUrlResult(CreateShortUrlDTO(alias));
                }
            }

            return(result);
        }
Beispiel #2
0
 public void IsValid_should_return_correct_value(string value, bool result)
 {
     Assert.Equal(result, basex.IsValid(value));
 }