Ejemplo n.º 1
0
        public void GenerateCorrectCheckUrl(
            WebPurifyCheckMethod method,
            string methodname,
            bool semail,
            bool sphone,
            string lang,
            WebPurifySupportedLanguage language)
        {
            // arrange
            const string urlCheckFormat = "{0}?method={1}&api_key={2}&text={3}&semail={4}&sphone={5}&lang={6}";
            string       expectedurl    = string.Format(
                urlCheckFormat,
                _apiUrl,
                methodname,
                _apikey,
                _text,
                WebPurifyUrlParameters.ToUrl(semail),
                WebPurifyUrlParameters.ToUrl(sphone),
                lang);

            // act
            string resulturl = _request.GetCheckUrl(_text, method, semail, sphone, language);

            // assert
            Assert.AreEqual(expectedurl, resulturl);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Check Request handles check, checkout, return methods.
 /// </summary>
 /// <param name="text">
 /// The text to be checked.
 /// </param>
 /// <param name="method">
 /// Choose the check, checkout or return methods.
 /// </param>
 /// <param name="matchEmail">
 /// if true, email is treated as profanity.
 /// </param>
 /// <param name="matchPhoneNumber">
 /// if true, phone numbers are treated as profanity.
 /// </param>
 /// <param name="language">
 /// Choose a supported language.
 /// </param>
 /// <returns>
 /// WebPurifyCheckResponse object
 /// </returns>
 public WebPurifyCheckResponse Check(
     string text,
     WebPurifyCheckMethod method,
     bool matchEmail       = false,
     bool matchPhoneNumber = false,
     WebPurifySupportedLanguage language = WebPurifySupportedLanguage.English)
 {
     return(this.webPurifyService.Check(this.GetCheckUrl(text, method, matchEmail, matchPhoneNumber, language)));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// The get check url.
 /// </summary>
 /// <param name="text">
 /// The text.
 /// </param>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <param name="matchEmail">
 /// The match email.
 /// </param>
 /// <param name="matchPhoneNumber">
 /// The match phone number.
 /// </param>
 /// <param name="language">
 /// The language.
 /// </param>
 /// <returns>
 /// returns URL for Web Purify REST service.
 /// </returns>
 internal string GetCheckUrl(
     string text,
     WebPurifyCheckMethod method,
     bool matchEmail,
     bool matchPhoneNumber,
     WebPurifySupportedLanguage language)
 {
     return
         (this.url.AddMethod(method).AddParam(WebPurifyArgument.ApiKey, this.key).AddParam(
              WebPurifyArgument.Text, text).AddParam(WebPurifyArgument.CheckEmail, matchEmail.ToUrl()).AddParam(
              WebPurifyArgument.CheckPhone, matchPhoneNumber.ToUrl()).AddParam(
              WebPurifyArgument.Language, WebPurifyUrlParameters.LanguageCode(language)));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// The check method text.
        /// </summary>
        /// <param name="method">
        /// The method.
        /// </param>
        /// <returns>
        /// returns either check, checkcount or return.
        /// </returns>
        public static string CheckMethodText(WebPurifyCheckMethod method)
        {
            switch (method)
            {
            case WebPurifyCheckMethod.Check:
                return("?method=webpurify.live.check");

            case WebPurifyCheckMethod.CheckCount:
                return("?method=webpurify.live.checkcount");

            case WebPurifyCheckMethod.Return:
            default:
                return("?method=webpurify.live.return");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// The add method.
 /// </summary>
 /// <param name="url">
 /// The url.
 /// </param>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <returns>
 /// adds the correct check method to the REST url.
 /// </returns>
 public static string AddMethod(this string url, WebPurifyCheckMethod method)
 {
     return(url + CheckMethodText(method));
 }
 /// <summary>
 /// The add method.
 /// </summary>
 /// <param name="url">
 /// The url.
 /// </param>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <returns>
 /// adds the correct check method to the REST url.
 /// </returns>
 public static string AddMethod(this string url, WebPurifyCheckMethod method)
 {
     return url + CheckMethodText(method);
 }
 /// <summary>
 /// The check method text.
 /// </summary>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <returns>
 /// returns either check, checkcount or return.
 /// </returns>
 public static string CheckMethodText(WebPurifyCheckMethod method)
 {
     switch (method)
     {
         case WebPurifyCheckMethod.Check:
             return "?method=webpurify.live.check";
         case WebPurifyCheckMethod.CheckCount:
             return "?method=webpurify.live.checkcount";
         case WebPurifyCheckMethod.Return:
         default:
             return "?method=webpurify.live.return";
     }
 }
        public void GenerateCorrectCheckUrl(
            WebPurifyCheckMethod method, 
            string methodname, 
            bool semail, 
            bool sphone, 
            string lang, 
            WebPurifySupportedLanguage language)
        {
            // arrange
            const string urlCheckFormat = "{0}?method={1}&api_key={2}&text={3}&semail={4}&sphone={5}&lang={6}";
            string expectedurl = string.Format(
                urlCheckFormat, 
                _apiUrl, 
                methodname, 
                _apikey, 
                _text, 
                WebPurifyUrlParameters.ToUrl(semail), 
                WebPurifyUrlParameters.ToUrl(sphone), 
                lang);

            // act
            string resulturl = _request.GetCheckUrl(_text, method, semail, sphone, language);

            // assert
            Assert.AreEqual(expectedurl, resulturl);
        }
 /// <summary>
 /// The get check url.
 /// </summary>
 /// <param name="text">
 /// The text.
 /// </param>
 /// <param name="method">
 /// The method.
 /// </param>
 /// <param name="matchEmail">
 /// The match email.
 /// </param>
 /// <param name="matchPhoneNumber">
 /// The match phone number.
 /// </param>
 /// <param name="language">
 /// The language.
 /// </param>
 /// <returns>
 /// returns URL for Web Purify REST service.
 /// </returns>
 internal string GetCheckUrl(
     string text, 
     WebPurifyCheckMethod method, 
     bool matchEmail, 
     bool matchPhoneNumber, 
     WebPurifySupportedLanguage language)
 {
     return
             this.url.AddMethod(method).AddParam(WebPurifyArgument.ApiKey, this.key).AddParam(
                 WebPurifyArgument.Text, text).AddParam(WebPurifyArgument.CheckEmail, matchEmail.ToUrl()).AddParam(
                     WebPurifyArgument.CheckPhone, matchPhoneNumber.ToUrl()).AddParam(
                         WebPurifyArgument.Language, WebPurifyUrlParameters.LanguageCode(language));
 }
 /// <summary>
 /// Check Request handles check, checkout, return methods.
 /// </summary>
 /// <param name="text">
 /// The text to be checked.
 /// </param>
 /// <param name="method">
 /// Choose the check, checkout or return methods.
 /// </param>
 /// <param name="matchEmail">
 /// if true, email is treated as profanity.
 /// </param>
 /// <param name="matchPhoneNumber">
 /// if true, phone numbers are treated as profanity.
 /// </param>
 /// <param name="language">
 /// Choose a supported language.
 /// </param>
 /// <returns>
 /// WebPurifyCheckResponse object
 /// </returns>
 public WebPurifyCheckResponse Check(
     string text, 
     WebPurifyCheckMethod method, 
     bool matchEmail = false, 
     bool matchPhoneNumber = false, 
     WebPurifySupportedLanguage language = WebPurifySupportedLanguage.English)
 {
     return this.webPurifyService.Check(this.GetCheckUrl(text, method, matchEmail, matchPhoneNumber, language));
 }