コード例 #1
0
        public void CorrelateEmptyArrayToFullArray()
        {
            var array1 = new string[0];
            var array2 = new[] { "A", "B", "C" };

            var expectedResult = new CorrelaterResult <string>(insertionCost * array2.Length, new string[3], array2);

            correlater.AssertComparision(array1, array2, expectedResult);
        }
コード例 #2
0
        public void DifrentInsertionCosts2()
        {
            var removalCalculator = A.Fake <IInsertionCalculator <string> >();
            var correlater        = new LevenshteinCorrelater <string>(new BasicDistanceCalculator <string>(10), new BasicRemovalCalculator <string>(10), removalCalculator);

            A.CallTo(() => removalCalculator.InsertionCost(A <string> ._)).ReturnsLazily(
                (string s) =>
            {
                if (s == "A")
                {
                    return(1);
                }
                if (s == "B")
                {
                    return(2);
                }
                return((uint)3);
            });

            var array1 = new string[0];
            var array2 = new[] { "A", "B" };

            var expectedResult = new CorrelaterResult <string>(3, new string[] { null, null }, array2);

            correlater.AssertComparision(array1, array2, expectedResult);
        }
コード例 #3
0
        public void DifrentDistnaceCosts()
        {
            var distanceCalculator = A.Fake <IDistanceCalculator <string> >();
            var correlater         = new LevenshteinCorrelater <string>(distanceCalculator, 2, 2);

            A.CallTo(() => distanceCalculator.Distance(A <string> ._, A <string> ._)).ReturnsLazily(
                (string s1, string s2) =>
            {
                if (s1 == s2)
                {
                    return(0);
                }
                if (s2 == "A" && s1 == "E")
                {
                    return(1);
                }
                return((uint)10);
            });


            var array1 = new[] { "V", "E" };
            var array2 = new[] { "T", "A" };

            var expectedResult = new CorrelaterResult <string>(5,
                                                               new[] { null, "V", "E" }, new[] { "T", null, "A" });

            correlater.AssertComparision(array1, array2, expectedResult);
        }
コード例 #4
0
        public void CorrelateString()
        {
            var string1 = "abc";
            var string2 = "ac";

            var expectedResult = new CorrelaterResult <char>(removalCost, string1.ToCharArray(), "a\0c".ToCharArray());

            var stringCorrelater = new LevenshteinCorrelater <char>(missmatchCost, removalCost, insertionCost);

            stringCorrelater.AssertComparision(string1, string2, expectedResult);
        }
コード例 #5
0
        public void DifrentInsertionCosts1()
        {
            var removalCalculator = A.Fake <IInsertionCalculator <string> >();
            var correlater        = new LevenshteinCorrelater <string>(new BasicDistanceCalculator <string>(10), new BasicRemovalCalculator <string>(10), removalCalculator);

            A.CallTo(() => removalCalculator.InsertionCost(A <string> ._)).ReturnsLazily(
                (string s) => s == "A" ? (uint)1 : 40);

            var array1 = new[] { "C" };
            var array2 = new[] { "A", "E" };

            var expectedResult = new CorrelaterResult <string>(11, new[] { null, "C" }, array2);

            correlater.AssertComparision(array1, array2, expectedResult);
        }