public void GetListOfClosestWordsFuncTest() { // arrange ILevenshteinDistance levDist = new WagnerFischer(); List<string> origWords = new List<string>() { "First", "Second", "Third", "Fourth", "Fifth", "Sixth" }; MockDictionaryFileFiller filler = new MockDictionaryFileFiller(origWords); WordsDictionary dic = new WordsDictionary(levDist, filler); List<string> resWords = new List<string>() { "First", "Fifth" }; // act List<string> res = dic.GetClosestWords("Funci"); // assert Assert.IsTrue(Enumerable.SequenceEqual(resWords, res)); }
public void CalcLevenshteinDistanceBothNullArgumentsTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act, assert int distance = levDistance.CalcLevenshteinDistance(null, null); }
public void CalcLevenshteinDistanceDeletionTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act int distance = levDistance.CalcLevenshteinDistance("distance", "ditance"); // assert Assert.AreEqual(levDistance.DeletionWeight, distance); }
public void CalcLevenshteinDistanceBothEmptyStringTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act, assert int distance = levDistance.CalcLevenshteinDistance("", ""); // assert Assert.AreEqual(0, distance); }
public void CalcLevenshteinDistanceDeletionReplacementTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); string testString1 = "ghosts"; string testString2 = "opera"; // act int distance = levDistance.CalcLevenshteinDistance(testString1, testString2); // assert Assert.AreEqual(levDistance.ReplacementWeight * testString2.Length + (testString1.Length - testString2.Length) * levDistance.DeletionWeight, distance); }
public void CalcLevenshteinDistanceEqualTest() { //arrange ILevenshteinDistance levDistance = new WagnerFischer(); //act int distance = levDistance.CalcLevenshteinDistance("excellent", "excellent"); //assert Assert.AreEqual(0, distance); }
public void CalcLevenshteinDistanceSecondNullArgumentTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act, assert int distance = levDistance.CalcLevenshteinDistance("Stroka1", null); }
public void CalcLevenshteinDistanceSecondEmptyStringTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); string testString = "Stroka2"; // act int distance = levDistance.CalcLevenshteinDistance(testString, ""); // assert Assert.AreEqual(testString.Length * levDistance.DeletionWeight, distance); }
public void CalcLevenshteinDistanceReplacementTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act int distance = levDistance.CalcLevenshteinDistance("yandex", "yardex"); // assert Assert.AreEqual(levDistance.ReplacementWeight, distance); }
public void CalcLevenshteinDistanceInsertionTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act int distance = levDistance.CalcLevenshteinDistance("opera", "hopera"); // assert Assert.AreEqual(levDistance.InsertionWeight, distance); }
public void CalcLevenshteinDistanceFirstNullArgumentTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); // act, assert int distance = levDistance.CalcLevenshteinDistance(null, "Stroka2"); }
public void CalcLevenshteinDistanceFirstEmptyStringTest() { // arrange ILevenshteinDistance levDistance = new WagnerFischer(); string testString = "Stroka"; // act int distance = levDistance.CalcLevenshteinDistance("", testString); // assert Assert.AreEqual(testString.Length * levDistance.InsertionWeight, distance); }