Exemple #1
0
        public void Compare_IgnoreCase_true(string def)
        {
            var tolerance = new TextToleranceFactory().Instantiate(def);
            var comparer  = new TextComparer();
            var result    = comparer.Compare("Seddryck", "seddryck", tolerance);

            Assert.That(result.AreEqual, Is.True);
        }
Exemple #2
0
        public void Compare_LargeDifference_False(string def)
        {
            var tolerance = new TextToleranceFactory().Instantiate(def);
            var comparer  = new TextComparer();
            var result    = comparer.Compare("Seddryck", "Undefined", tolerance);

            Assert.That(result.AreEqual, Is.False);
        }
        public void Instantiate_StartsWithCasingNameInt32_Instantiated()
        {
            var tolerance = new TextToleranceFactory().Instantiate("hamming(0.8)");

            Assert.That(tolerance, Is.TypeOf <TextTolerance>());
            Assert.That(tolerance.Style, Is.EqualTo("Hamming distance"));
            Assert.That(tolerance.Value, Is.EqualTo(0.8).Within(0.001));
            Assert.That(tolerance.Implementation, Is.Not.Null);
            Assert.That(tolerance.Implementation("alpha", "alpha"), Is.EqualTo(0));
        }
        public void Instantiate_ExactNameInt32_Instantiated()
        {
            var tolerance = new TextToleranceFactory().Instantiate("LevenshteinDistance(0.8)");

            Assert.That(tolerance, Is.TypeOf <TextTolerance>());
            Assert.That(tolerance.Style, Is.EqualTo("Levenshtein distance"));
            Assert.That(tolerance.Value, Is.EqualTo(0.8).Within(0.001));
            Assert.That(tolerance.Implementation, Is.Not.Null);
            Assert.That(tolerance.Implementation("alpha", "alpha"), Is.EqualTo(0));
        }
        public void Instantiate_ExactNameWithSpaceDouble_Instantiated()
        {
            var tolerance = new TextToleranceFactory().Instantiate("jaccard disTance(0.8)");

            Assert.That(tolerance, Is.TypeOf <TextTolerance>());
            Assert.That(tolerance.Style, Is.EqualTo("Jaccard distance"));
            Assert.That(tolerance.Value, Is.EqualTo(0.8).Within(0.001));
            Assert.That(tolerance.Implementation, Is.Not.Null);
            Assert.That(tolerance.Implementation("alpha", "alpha"), Is.EqualTo(0));
        }
        public void Instantiate_Decimal_Instantiated(string culture)
        {
            var currentCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
            var tolerance = new TextToleranceFactory().Instantiate("JaccardDistance(0.8)");

            Thread.CurrentThread.CurrentCulture = currentCulture;

            Assert.That(tolerance, Is.TypeOf <TextSingleMethodTolerance>());
            Assert.That((tolerance as TextSingleMethodTolerance).Value, Is.EqualTo(0.8).Within(0.001));
        }
        public void Instantiate_TwoMethodsAbbreviatedNames_Instantiated()
        {
            var textTolerance = new TextToleranceFactory().Instantiate("Overlap, Jaro-Winkler (weak )");

            Assert.That(textTolerance, Is.TypeOf <TextMultipleMethodsTolerance>());
            var tolerance = textTolerance as TextMultipleMethodsTolerance;

            Assert.That(tolerance.Style, Is.EqualTo("UseOverlapCoefficient, UseJaroWinklerDistance"));
            Assert.That(tolerance.Value, Is.EqualTo("Weak"));
            Assert.That(tolerance.Implementation, Is.Not.Null);
            Assert.That(tolerance.Implementation("je t'aime", "je t'eme"), Is.True);
        }