/// <summary>
        /// Set the match level by which to compare the screenshot.
        /// </summary>
        /// <param name="matchLevel">The match level to use.</param>
        /// <returns>An updated clone of this settings object.</returns>
        public ICheckSettings MatchLevel(MatchLevel matchLevel)
        {
            CheckSettings clone = Clone();

            clone.matchLevel_ = matchLevel;
            return(clone);
        }
            private static MatchLevel Compare(Type thisSideType, Association thisSide, Type otherSideType,
                                              Association otherSide)
            {
                MatchLevel noMatch = MatchLevel.NoMatch;

                if (((thisSide.IsForeignKey == true) && (otherSide.IsForeignKey != true)) ||
                    ((thisSide.IsForeignKey != true) && (otherSide.IsForeignKey == true)))
                {
                    noMatch = noMatch;
                }
                if (thisSideType.Name == otherSide.Type)
                {
                    noMatch |= MatchLevel.ThisTypeAgrees;
                }
                if (otherSideType.Name == thisSide.Type)
                {
                    noMatch |= MatchLevel.OtherTypeAgrees;
                }
                if (BuildKeyField(thisSide.GetOtherKey()) == BuildKeyField(otherSide.GetThisKey()))
                {
                    noMatch |= MatchLevel.ThisOtherKeyMatchesOtherThisKey;
                }
                if (BuildKeyField(thisSide.GetThisKey()) == BuildKeyField(otherSide.GetOtherKey()))
                {
                    noMatch |= MatchLevel.ThisThisKeyMatchisOtherOtherKey;
                }
                return(noMatch);
            }
        public void TestEyesDifferentRunners(string testedUrl, MatchLevel matchLevel)
        {
            IWebDriver webDriver = SeleniumUtils.CreateChromeDriver();
            Logger     logger    = null;
            Eyes       eyes      = null;

            try
            {
                webDriver.Url     = testedUrl;
                eyes              = InitEyes(webDriver, testedUrl);
                eyes.SaveNewTests = false;
                logger            = eyes.Logger;
                logger.Log("running check for url " + testedUrl);
                ICheckSettings checkSettings = GetCheckSettings();
                eyes.MatchLevel = matchLevel;
                eyes.Check(checkSettings.WithName("Step1 - " + testedUrl));
                eyes.Check(checkSettings.Fully().WithName("Step2 - " + testedUrl));
                logger.Verbose("calling eyes_.Close() (test: {0})", testedUrl);
                TestResults results = eyes.Close(false);
                ValidateResults(eyes, results);
            }
            finally
            {
                eyes?.Abort();
                webDriver.Quit();
            }
        }
        internal Response(ReturnCode result,
                          string postcode,
                          int? addressId,
                          AddressType? addressType,
                          MatchLevel matchLevel,
                          string[] postalAddress,
                          AddressElement[] postalAddressElements,
                          string[] geographicAddress,
                          AddressElement[] geographicAddressElements,
                          string[] vanityAddress,
                          AddressElement[] vanityAddressElements,
                          ReformattedAddressResult? reformattedAddressResult,
                          string[] reformattedAddress,
                          int totalOptions,
                          Option[] options,
                          Request input,
                          Model.Link[] links
            )
        {
            if (links == null) throw new ArgumentNullException("links");

            Result = result;
            Postcode = postcode;
            AddressId = addressId;
            AddressType = addressType;
            MatchLevel = matchLevel;
            PostalAddress = postalAddress;
            PostalAddressElements = postalAddressElements;
            GeographicAddress = geographicAddress;
            GeographicAddressElements = geographicAddressElements;
            VanityAddress = vanityAddress;
            VanityAddressElements = vanityAddressElements;
            ReformattedAddressResult = reformattedAddressResult;
            ReformattedAddress = reformattedAddress;
            TotalOptions = totalOptions;
            Options = options;
            Input = input;

            var newLinks = new List<Model.Link>();

            foreach (Model.Link link in links)
            {
                Model.Link newLink;

                switch (link.Rel)
                {
                    case "self":
                        newLink = new Model.PostcodeLookup.Link(link.Rel, link.Href);
                        break;
                    default:
                        newLink = link;
                        break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }
示例#5
0
        /// <summary>
        /// Set the match level by which to compare the screenshot.
        /// </summary>
        /// <param name="matchLevel">The match level to use.</param>
        /// <returns>An updated clone of this settings object.</returns>
        public ICheckSettings MatchLevel(MatchLevel matchLevel)
        {
            CheckSettings clone = Clone();

            clone.matchLevel_ = matchLevel;
            clone.fluentCode_.Append($".{nameof(MatchLevel)}({nameof(MatchLevel)}.{matchLevel})");
            return(clone);
        }
示例#6
0
 private void MatchTagHelper1(
     int expected,
     string lhs,
     string rhs,
     MatchLevel matchLevel = MatchLevel.LanguageMatch)
 {
     Assert.Equal(expected, (LanguageTagManager.Create(lhs).Match(LanguageTagManager.Create(rhs), matchLevel)));
     Assert.Equal(expected, (LanguageTagManager.Create(rhs).Match(LanguageTagManager.Create(lhs), matchLevel)));
 }
示例#7
0
        public void FullCheckPricingPage(int screenWidth, int screenHeight, MatchLevel matchLevel)
        {
            this.testName        = string.Format("{0}: {1}x{2}px ({3} level)", MethodBase.GetCurrentMethod().Name, screenWidth, screenHeight, matchLevel);
            this.Eyes.MatchLevel = matchLevel;
            this.Eyes.ForceFullPageScreenshot = true;
            this.Eyes.StitchMode = StitchModes.CSS;
            this.Eyes.Open(this.Driver, this.AppName, this.testName, new Size(screenWidth, screenHeight));

            this.fakePricingPage.Open();
            this.fakePricingPage.ScrollToBottom();
            this.fakePricingPage.ScrollToTop();

            this.Eyes.Check(Target.Window().Fully());
        }
示例#8
0
 private void MatchTagHelper(
     int expected,
     string lhs,
     string rhs,
     MatchLevel matchLevel = MatchLevel.LanguageMatch)
 {
     MatchTagHelper1(expected, lhs, rhs, matchLevel);
     // If PrivateUse subtag not present in either tag...append such a subtag equally to both sides
     // and test again. This should have no effect on the result.
     if (-1 == lhs.IndexOf("-x-", StringComparison.OrdinalIgnoreCase) && -1 == rhs.IndexOf("-x-", StringComparison.OrdinalIgnoreCase))
     {
         MatchTagHelper1(expected, lhs + "-x-abcd", rhs + "-x-abcd", matchLevel);
     }
 }
示例#9
0
        public void CheckPricingPageBySections(int screenWidth, int screenHeight, MatchLevel matchLevel)
        {
            this.testName        = string.Format("{0}: {1}x{2}px ({3} level)", MethodBase.GetCurrentMethod().Name, screenWidth, screenHeight, matchLevel);
            this.Eyes.MatchLevel = matchLevel;
            this.Eyes.Open(this.Driver, this.AppName, this.testName, new Size(screenWidth, screenHeight));

            this.fakePricingPage.Open();
            this.Eyes.CheckWindow("Offset: " + this.Javascript.ExecuteScript("return window.scrollY") + "px");

            int scrollRepeats = this.fakePricingPage.PageHeight / this.fakePricingPage.PageInnerHeight;

            for (int i = 0; i < scrollRepeats; i++)
            {
                this.fakePricingPage.ScrollWithInnerHeight();
                this.Eyes.CheckWindow("Offset: " + this.Javascript.ExecuteScript("return window.scrollY") + "px");
            }
        }
示例#10
0
        internal Response(ReturnCode result,
                          string postcode,
                          int?addressId,
                          AddressType?addressType,
                          MatchLevel matchLevel,
                          string[] postalAddress,
                          AddressElement[] postalAddressElements,
                          string[] geographicAddress,
                          AddressElement[] geographicAddressElements,
                          string[] vanityAddress,
                          AddressElement[] vanityAddressElements,
                          ReformattedAddressResult?reformattedAddressResult,
                          string[] reformattedAddress,
                          int totalOptions,
                          Option[] options,
                          Request input,
                          Model.Link[] links
                          )
        {
            if (links == null)
            {
                throw new ArgumentNullException("links");
            }

            Result                    = result;
            Postcode                  = postcode;
            AddressId                 = addressId;
            AddressType               = addressType;
            MatchLevel                = matchLevel;
            PostalAddress             = postalAddress;
            PostalAddressElements     = postalAddressElements;
            GeographicAddress         = geographicAddress;
            GeographicAddressElements = geographicAddressElements;
            VanityAddress             = vanityAddress;
            VanityAddressElements     = vanityAddressElements;
            ReformattedAddressResult  = reformattedAddressResult;
            ReformattedAddress        = reformattedAddress;
            TotalOptions              = totalOptions;
            Options                   = options;
            Input = input;

            var newLinks = new List <Model.Link>();

            foreach (Model.Link link in links)
            {
                Model.Link newLink;

                switch (link.Rel)
                {
                case "self":
                    newLink = new Model.PostcodeLookup.Link(link.Rel, link.Href);
                    break;

                default:
                    newLink = link;
                    break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }
示例#11
0
 private static Meta Meta(string field, MatchLevel matchLevel)
 {
     return(new Meta(field, matchLevel));
 }
示例#12
0
 public Meta(string field, MatchLevel matchLevel)
 {
     Field           = field;
     this.matchLevel = matchLevel;
 }
        /// <summary>
        /// Looks up in the passed collection of supported AppLanguages the language that is best matched
        /// to this langtag. I.e. the written AppLanguage that a user understanding this langtag
        /// will most-likely understand.
        /// </summary>
        /// <param name="leftLanguageTag"></param>
        /// <param name="rightLanguageTags"></param>
        /// <param name="matchedTag"></param>
        /// <param name="matchLevel"></param>
        /// <returns>Selected CultureInfoEx instance from the AppLanguages collection or null if there was no match.</returns>
        public static int Match(LanguageTag leftLanguageTag, LanguageTag[] rightLanguageTags, out LanguageTag matchedTag, MatchLevel matchLevel = MatchLevel.LanguageMatch)
        {
            int matchedScore = 0;

            matchedTag = null;
            foreach (LanguageTag rightLanguageTag in rightLanguageTags)
            {
                int score = Match(leftLanguageTag, rightLanguageTag, matchLevel);
                if (score > matchedScore)
                {
                    matchedScore = score;
                    matchedTag   = rightLanguageTag;
                    if (matchedScore == 100)
                    {
                        // Can't beat an exact match.
                        break;
                    }
                }
            }

            return(matchedScore);
        }
        /// <summary>
        /// Performs 'language matching' between lang described by this (A)
        /// and language decibed by i_rhs (B). Essentially, returns an assessment of
        /// how well a speaker of A will understand B.
        /// The key points are as follows:
        ///   · The Script is almost as relevant as the language itself; that is, if
        ///     you speak a language but do not understand the script, you cannot
        ///     read that language. Thus a mismatch in Script should score low.
        ///   · The Region is less relevant than Script to understanding of language.
        ///     The one exception to this is where the Region has traditionally been
        ///     used to also indicate the Script. E.g.
        ///         zh-CH -> Chinese (Simplified)  i.e. zh-Hans
        ///         zh-TW -> Chinese (Traditional) i.e. zh-Hant
        ///     In these cases we normalize all legacy langtags to their new values
        ///     before matching. E.g. zh-CH is normalized to zh-Hans.
        /// «LX113»
        /// </summary>
        /// <param name="leftLanguageTag"></param>
        /// <param name="rightLanguageTag"></param>
        /// <param name="matchLevel"></param>
        /// <returns>
        /// Returns a score on to what extent the two languages match. The value ranges from
        /// 100 (exact match) down to 0 (fundamental language tag mismatch), with values
        /// in between which may be used to compare quality of a match, larger the value
        /// meaning better quality.
        /// </returns>
        /// <remarks>
        /// Matching values:
        ///                                              RHS
        /// this                    lang    lang+script     lang+region     lang+script+region
        /// ----------------------------------------------------------------------------------
        /// lang                |   A       D               C               D
        /// lang+script         |   D       A               D               B
        /// lang+region         |   C       D               A               D
        /// lang+script+region  |   D       B               D               A
        ///
        /// NB: For the purposes of the logic above, lang incorporates Language + PrivateUse subtags.
        ///
        /// A. Exact match (100)
        ///     All three subtags match.
        /// B. Unbalanced Region Mismatch (99) [zh, zh-HK] [zh-Hans, zh-Hans-HK]
        ///     Language and Script match;
        ///     one side has Region set while the other doesn't.
        ///     Here there is the possibility that due to defaults Region matches.
        /// C. Balanced Region Mismatch (98) [zh-IK, zh-HK] [zh-Hans-IK, zh-Hans-HK]
        ///     Language and Script match;
        ///     both sides have Region set but to different values.
        ///     Here there is NO possibility that Region matches.
        /// D. Unbalanced Script Mismatch (97) [zh-HK, zh-Hant-HK]
        ///     Language matches, Region may match;
        ///     one side has Script set while the other doesn't.
        ///     Here there is the possibility that due to defaults Script matches.
        /// E. Balanced Script Mismatch (96)
        ///     Language matches, Region may match;
        ///     both sides have Script set but to different values.
        ///     Here there is NO possibility that Script matches.
        /// F. Language Mismatch (0)
        ///     Language doesn't match.
        /// </remarks>
        /// <seealso href="http://msdn.microsoft.com/en-us/library/windows/apps/jj673578.aspx"/>
        public static int Match(LanguageTag leftLanguageTag, LanguageTag rightLanguageTag, MatchLevel matchLevel = MatchLevel.LanguageMatch)
        {
            if (leftLanguageTag == null)
            {
                throw new ArgumentNullException(nameof(leftLanguageTag));
            }

            if (rightLanguageTag == null)
            {
                throw new ArgumentNullException(nameof(rightLanguageTag));
            }

            if (leftLanguageTag.Language.IsNullOrEmpty() || rightLanguageTag.Language.IsNullOrEmpty())
            {
                return(0);
            }

            //Init
            bool[] init(string l, string r) => new[] { 0 == string.Compare(l, r, StringComparison.OrdinalIgnoreCase), l.IsNotNullNorEmpty(), r.IsNotNullNorEmpty() };
            var L = init(leftLanguageTag.Language, rightLanguageTag.Language);
            var S = init(leftLanguageTag.Script, rightLanguageTag.Script);
            var R = init(leftLanguageTag.Region, rightLanguageTag.Region);
            var P = init(leftLanguageTag.PrivateUse, rightLanguageTag.PrivateUse);

            // Language incorporates Language + PrivateUse subtags for our logic here.
            L[0] = L[0] && P[0];
            L[1] = L[1] || P[1];
            L[2] = L[2] || P[2];

            // Logic.
            int score = 100;

            // F.
            if (!L[0])
            {
                return(0);
            }

            // A.
            if (S[0] && R[0] && P[0])
            {
                return(score);
            }

            --score;
            if (matchLevel != MatchLevel.ExactMatch)
            {
                // B.
                if (S[0] && !R[0] && R[1] != R[2])
                {
                    return(score);
                }

                --score;
                if (matchLevel != MatchLevel.DefaultRegion)
                {
                    // C.
                    if (S[0] && !R[0] && R[1] == R[2])
                    {
                        return(score);
                    }

                    --score;
                    if (matchLevel != MatchLevel.ScriptMatch)
                    {
                        // D.
                        if (!S[0] && S[1] != S[2])
                        {
                            return(score);
                        }

                        --score;
                        // E.
                        if (!S[0] && S[1] == S[2])
                        {
                            return(score);
                        }
                    }

                    //--score;
                }
            }

            // F.
            return(0);
        }
示例#15
0
 public new IConfiguration SetMatchLevel(MatchLevel value) => (IConfiguration)base.SetMatchLevel(value);
        private IEnumerable <FallbackItem> Filter(List <FallbackItem> orderedItems, LanguageTag languageTag, MatchLevel matchLevel, List <int> skipHashCodes)
        {
            foreach (var item in orderedItems)
            {
                if (skipHashCodes.Contains(item.HashCodeCached))
                {
                    continue;
                }
                var score = LanguageTagMatcher.Match(languageTag, item.Value, matchLevel);

                if (score > 0)
                {
                    skipHashCodes.Add(item.HashCodeCached);
                    yield return(item);
                }
            }
        }
示例#17
0
 /// <summary>
 /// Match
 /// </summary>
 /// <param name="appLanguages"></param>
 /// <param name="matchedTag"></param>
 /// <param name="matchLevel"></param>
 /// <returns></returns>
 public int Match(LanguageTag[] appLanguages, out LanguageTag matchedTag, MatchLevel matchLevel = MatchLevel.LanguageMatch)
 {
     return(LanguageTagMatcher.Match(this, appLanguages, out matchedTag, matchLevel));
 }
示例#18
0
            public MatchResult withLevel(MatchLevel value)
            {
                level = value;

                return(this);
            }
示例#19
0
 /// <summary>
 /// Match
 /// </summary>
 /// <param name="appLanguage"></param>
 /// <param name="matchLevel"></param>
 /// <returns></returns>
 public int Match(LanguageTag appLanguage, MatchLevel matchLevel = MatchLevel.LanguageMatch)
 {
     return(LanguageTagMatcher.Match(this, appLanguage, matchLevel));
 }
            public static Dictionary <Association, Association> Gather(Database db)
            {
                var associations = new PairAssociations();

                associations.VisitDatabase(db);
                var dictionary = new Dictionary <Association, Association>();

                foreach (string str in associations.associations.Keys)
                {
                    Association[] associationArray = associations.associations[str].ToArray();
                    int           length           = associationArray.Length;
                    int           num2             = 0;
                    while (num2 != length)
                    {
                        int        index   = -1;
                        int        num4    = -1;
                        MatchLevel noMatch = MatchLevel.NoMatch;
                        for (int i = 0; i < (length - 1); i++)
                        {
                            for (int j = i + 1; j < length; j++)
                            {
                                Association thisSide  = associationArray[i];
                                Association otherSide = associationArray[j];
                                if ((thisSide != null) && (otherSide != null))
                                {
                                    MatchLevel level2 = Compare(associations.associationTypes[thisSide], thisSide,
                                                                associations.associationTypes[otherSide], otherSide);
                                    if (level2 > noMatch)
                                    {
                                        index   = i;
                                        num4    = j;
                                        noMatch = level2;
                                    }
                                }
                            }
                        }
                        if ((noMatch & MatchLevel.MinBar) == MatchLevel.MinBar)
                        {
                            Association association3 = associationArray[index];
                            Association association4 = associationArray[num4];
                            dictionary[association3] = association4;
                            dictionary[association4] = association3;
                            associationArray[index]  = null;
                            associationArray[num4]   = null;
                            num2 += 2;
                        }
                        else
                        {
                            foreach (Association association5 in associationArray)
                            {
                                if (association5 != null)
                                {
                                    dictionary[association5] = null;
                                    num2++;
                                }
                            }
                        }
                    }
                }
                return(dictionary);
            }
示例#21
0
 public new AppiumCheckSettings MatchLevel(MatchLevel matchLevel)
 {
     return((AppiumCheckSettings)base.MatchLevel(matchLevel));
 }
示例#22
0
 public MatchQuality(MatchLevel genderMatchQuality, MatchLevel ageMatchQuality)
 {
     GenderMatchQuality = genderMatchQuality;
     AgeMatchQuality    = ageMatchQuality;
 }
 public new SeleniumCheckSettings MatchLevel(MatchLevel matchLevel)
 {
     return((SeleniumCheckSettings)base.MatchLevel(matchLevel));
 }