コード例 #1
0
        private static void NoMatchesForInputWordInnerTest(bool allowDuplicateWords)
        {
            Word2Trie       trie   = new Word2Trie();
            Word2GridFinder finder = new Word2GridFinder(trie, allowDuplicateWords);

            int count = 0;

            finder.Find(new Word2("ab"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #2
0
        private static void MatchInputWordButNoOtherWordsInnerTest(bool allowDuplicateWords)
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ab"));
            Word2GridFinder finder = new Word2GridFinder(trie, allowDuplicateWords);

            int count = 0;

            finder.Find(new Word2("ab"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #3
0
        public void Find_AllowDuplicatesMatchesFirstRowAndColumnButNoOtherWords_DoesNothing()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ab"));
            trie.Add(new Word2("az"));
            Word2GridFinder finder = new Word2GridFinder(trie, true);

            int count = 0;

            finder.Find(new Word2("ab"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #4
0
        public void Find_DisallowDuplicatesMismatchOnLastColumnWithSameLetters_DoesNothing()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("aa"));
            trie.Add(new Word2("ab"));
            trie.Add(new Word2("ba"));
            Word2GridFinder finder = new Word2GridFinder(trie, false);

            int count = 0;

            finder.Find(new Word2("aa"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #5
0
        private static void MismatchOnLastColumnInnerTest(bool allowDuplicateWords)
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ah"));
            trie.Add(new Word2("am"));
            trie.Add(new Word2("me"));
            Word2GridFinder finder = new Word2GridFinder(trie, allowDuplicateWords);

            int count = 0;

            finder.Find(new Word2("ah"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #6
0
        public void Find_DisallowDuplicatesNoMatchesWithThreeWords_DoesNothing()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ab"));
            trie.Add(new Word2("ac"));
            trie.Add(new Word2("bc"));
            Word2GridFinder finder = new Word2GridFinder(trie, false);

            int count = 0;

            finder.Find(new Word2("ab"), g => ++ count);

            Assert.Equal(0, count);
        }
コード例 #7
0
        public void Find_AllowDuplicatesExactlyOneMatchWithTwoWords_ExecutesOnFoundOnce()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ab"));
            trie.Add(new Word2("bb"));
            Word2GridFinder finder = new Word2GridFinder(trie, true);

            List <Word2Grid> grids = new List <Word2Grid>();

            finder.Find(new Word2("ab"), g => grids.Add(g));

            Assert.Equal(1, grids.Count);
            Assert.Equal(new Word2("ab"), grids[0].Row1);
            Assert.Equal(new Word2("bb"), grids[0].Row2);
        }
コード例 #8
0
        public void Find_DisallowDuplicatesExactlyOneMatchWithFourWords_ExecutesOnFoundOnce()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ah"));
            trie.Add(new Word2("am"));
            trie.Add(new Word2("me"));
            trie.Add(new Word2("he"));
            Word2GridFinder finder = new Word2GridFinder(trie, false);

            List <Word2Grid> grids = new List <Word2Grid>();

            finder.Find(new Word2("ah"), g => grids.Add(g));

            Assert.Equal(1, grids.Count);
            Assert.Equal(new Word2("ah"), grids[0].Row1);
            Assert.Equal(new Word2("me"), grids[0].Row2);
        }
コード例 #9
0
        public void Find_AllowDuplicatesTwoMatchesWithFourWords_ExecutesOnFoundTwice()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ah"));
            trie.Add(new Word2("am"));
            trie.Add(new Word2("me"));
            trie.Add(new Word2("he"));
            Word2GridFinder finder = new Word2GridFinder(trie, true);

            List <Word2Grid> grids = new List <Word2Grid>();

            finder.Find(new Word2("ah"), g => grids.Add(g));

            Assert.Equal(2, grids.Count);
            Assert.Equal(new Word2("ah"), grids[0].Row1);
            Assert.Equal(new Word2("he"), grids[0].Row2);
            Assert.Equal(new Word2("ah"), grids[1].Row1);
            Assert.Equal(new Word2("me"), grids[1].Row2);
        }
コード例 #10
0
        public void Find_DisallowDuplicatesExactlyTwoMatches_ExecutesOnFoundTwice()
        {
            Word2Trie trie = new Word2Trie();

            trie.Add(new Word2("ab"));
            trie.Add(new Word2("ac"));
            trie.Add(new Word2("bd"));
            trie.Add(new Word2("cd"));
            trie.Add(new Word2("ad"));
            trie.Add(new Word2("bc"));
            trie.Add(new Word2("dc"));
            Word2GridFinder finder = new Word2GridFinder(trie, false);

            List <Word2Grid> grids = new List <Word2Grid>();

            finder.Find(new Word2("ab"), g => grids.Add(g));

            Assert.Equal(2, grids.Count);
            Assert.Equal(new Word2("ab"), grids[0].Row1);
            Assert.Equal(new Word2("cd"), grids[0].Row2);
            Assert.Equal(new Word2("ab"), grids[1].Row1);
            Assert.Equal(new Word2("dc"), grids[1].Row2);
        }