Ejemplo n.º 1
0
            public void WHEN_ComputeSimilarityOfTwoIdenticalStrings_THEN_ScoreIs0()
            {
                testString1   = "abc";
                testString2   = "abc";
                expectedScore = 0;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 2
0
            public void WHEN_ComputeSimilarityWhereString2Wrong1CharBefore_THEN_ComputedScoreHas1Deduction()
            {
                testString1   = "ab";
                testString2   = "cb";
                expectedScore = 1;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 3
0
            public void WHEN_ComputeSimilarityWhereString2Empty_THEN_ComputedScoreHas1ScoreDeduction()
            {
                testString1   = "a";
                testString2   = "";
                expectedScore = 1;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 4
0
            public void WHEN_ComputeSimilarityWhereString2Missing2CharBetween_THEN_ComputedScoreHas2Deduction()
            {
                testString1   = "abcd";
                testString2   = "ad";
                expectedScore = 2;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 5
0
            public void WHEN_ComputeSimilarityWhereStringIs1000Characters_THEN_ComputedScoreIsCorrect()
            {
                testString1   = new string('a', 1000);
                testString2   = "a";
                expectedScore = 999;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 6
0
            public void WHEN_ComputeSimilarityWhereStringHasSymbolCharacters_THEN_ComputedScoreIsCorrect()
            {
                testString1   = "~`!@#$%^&*()_+-=[]\\{}|;':\",./<>?";
                testString2   = "a";
                expectedScore = 32;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 7
0
            public void WHEN_ComputeSimilarityWhereStringIsNumbers_THEN_ComputedScoreIsCorrect()
            {
                testString1   = "1234";
                testString2   = "1234";
                expectedScore = 0;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 8
0
            public void WHEN_ComputeSimilarityWhereStringHasEscapeCharacters_THEN_ComputedScoreIsCorrect()
            {
                // \' single quote, \" double quote, \\ backslash, \0 null character \a alert character \b backspace \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab
                testString1   = "\'\"\\\0\a\b\f\n\r\t\v";
                testString2   = "a";
                expectedScore = 11;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }
Ejemplo n.º 9
0
            public void WHEN_ComputeSimilarityWhereStringHasUnicodeCharacters_THEN_ComputedScoreIsCorrect()
            {
                // Unicode character format: \uxxxx for a unicode character hex value such as \u0020
                // \x is the same as \u, but you dont need leading zeros \x20

                testString1   = "\u0020";
                testString2   = "a";
                expectedScore = 1;

                StringSimilarity.ComputeSimilarity(testString1, testString2);

                Assert.AreEqual(expectedScore, StringSimilarity.GetTotalDiff());
            }