public void CompareStrings_ShouldGetComparerFromFactoryUsingType()
        {
            // Arrange
            FuzzyStringComparerType inputComparerType = FuzzyStringComparerType.LevenshteinDistance;

            // Act
            this.fuzzyStringComparer.CompareStrings(inputComparerType, "Test", "Test");

            // Assert
            factoryMock.Verify(f => f.GetFuzzyComparer(inputComparerType), Times.Once);
        }
Ejemplo n.º 2
0
        public IFuzzyComparerStrategy GetFuzzyComparer(FuzzyStringComparerType fuzzyComparerType)
        {
            switch (fuzzyComparerType)
            {
            case FuzzyStringComparerType.JaroDistance:
                return(new JaroDistanceFuzzyComparer());

            case FuzzyStringComparerType.LevenshteinDistance:
                return(new LevenshteinDistanceFuzzyComparer());

            case FuzzyStringComparerType.LevenshteinDistanceRecursive:
                return(new LevenshteinDistanceRecursiveFuzzyComparer());

            case FuzzyStringComparerType.LevenshteinDistancePercentage:
                return(new LevenshteinDistancePercentageFuzzyComparer(new LevenshteinDistanceFuzzyComparer()));

            default:
                throw new Exception("No comparer for the specified type");
            }
        }
Ejemplo n.º 3
0
        public double CompareStrings(FuzzyStringComparerType fuzzyComparerType, string stringOne, string stringTwo)
        {
            IFuzzyComparerStrategy comparerStrategy = fuzzyComparerFactory.GetFuzzyComparer(fuzzyComparerType);

            return(comparerStrategy.Compare(stringOne, stringTwo));
        }
Ejemplo n.º 4
0
        public void GetFuzzyComparer_ValidComparerType_ShouldReturnTheCorrectStrategy(FuzzyStringComparerType comparerType, string expectedComparerTypeName)
        {
            // Act
            IFuzzyComparerStrategy returnedComparer = this.fuzzyComparerFactory.GetFuzzyComparer(comparerType);

            // Assert
            Assert.AreEqual(expectedComparerTypeName, returnedComparer.GetType().Name);
        }