public void GetSuggestionCountTest()
        {
            try
            {
                SwipeType.SwipeType swipeType = new SimpleSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
                var testing = new Dictionary <string, List <string> >
                {
                    ["heqerqllo"] = new List <string>
                    {
                        "hello",
                        "hero",
                        "ho"
                    },
                    ["wertyuioiuytrtghjklkjhgfd"] = new List <string>
                    {
                        "weird",
                        "world",
                        "would"
                    },
                    ["dfghjioijhgvcftyuioiuytr"] = new List <string>
                    {
                        "doctor",
                        "door",
                        "dour"
                    },
                    ["asdfgrtyuijhvcvghuiklkjuytyuytre"] = new List <string>
                    {
                        "agriculture",
                        "article",
                        "adjure"
                    }
                };

                foreach (var s in testing)
                {
                    foreach (var x in swipeType.GetSuggestion(s.Key, 3))
                    {
                        s.Value.Remove(x);
                    }
                }

                foreach (var s in testing)
                {
                    if (s.Value.Count > 0)
                    {
                        Assert.Fail("GetSuggestionTest fail with new match");
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail($"GetSuggestionTest fail with exception: {ex}");
            }
        }
Пример #2
0
        private static void Main()
        {
            SwipeType simpleSwipeType = new SimpleSwipeType(File.ReadAllLines("EnglishDictionary.txt"));

            SampleUsingSwipeType(simpleSwipeType);
            Console.ReadKey(true);

            SwipeType distanceSwipeType = new DistanceSwipeType(File.ReadAllLines("EnglishDictionary.txt"));

            SampleUsingSwipeType(distanceSwipeType);
            Console.ReadKey(true);
        }
 public void SimpleSwipeTypeTest()
 {
     try
     {
         SwipeType.SwipeType swipeType = new SimpleSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
     }
     catch (OutOfMemoryException e)
     {
         Assert.Fail($"GetSuggestionTest fail with OutOfMemoryException: {e}");
     }
     catch (Exception ex)
     {
         Assert.Fail($"GetSuggestionTest fail with Exception: {ex}");
     }
 }
        public void GetSuggestionTest()
        {
            try
            {
                SwipeType.SwipeType swipeType = new SimpleSwipeType(File.ReadAllLines("EnglishDictionary.txt"));
                var testing = new Dictionary <string, List <string> >
                {
                    ["heqerqllo"] = new List <string>
                    {
                        "hello",
                        "hero",
                        "ho"
                    },
                    ["qwertyuihgfcvbnjk"] = new List <string>
                    {
                        "quick"
                    },
                    ["wertyuioiuytrtghjklkjhgfd"] = new List <string>
                    {
                        "weird",
                        "world",
                        "would",
                        "weld",
                        "wild",
                        "wold",
                        "word",
                        "wed"
                    },
                    ["dfghjioijhgvcftyuioiuytr"] = new List <string>
                    {
                        "doctor",
                        "door",
                        "dour"
                    },
                    ["aserfcvghjiuytedcftyuytre"] = new List <string>
                    {
                        "architecture",
                        "architecure"
                    },
                    ["asdfgrtyuijhvcvghuiklkjuytyuytre"] = new List <string>
                    {
                        "agriculture",
                        "article",
                        "adjure",
                        "astute"
                    },
                    ["mjuytfdsdftyuiuhgvc"] = new List <string>
                    {
                        "mystic",
                        "music"
                    },
                    ["vghjioiuhgvcxsasdvbhuiklkjhgfdsaserty"] = new List <string>
                    {
                        "vocabulary"
                    }
                };

                foreach (var s in testing)
                {
                    foreach (var x in swipeType.GetSuggestion(s.Key))
                    {
                        s.Value.Remove(x);
                    }
                }

                foreach (var s in testing)
                {
                    if (s.Value.Count > 0)
                    {
                        Assert.Fail("GetSuggestionTest fail with new match");
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail($"GetSuggestionTest fail with exception: {ex}");
            }
        }