Example #1
0
        public void ComputeWords_3Chars_Computed()
        {
            // arrange
            CharsGraph charsGraph = new CharsGraph(new List <string> {
                "ae", "ea", "ab", "ba", "bc", "cb", "abc", "cba", "bae", "eab", "eabc", "cbae"
            });

            // act
            charsGraph.AddEdge('a', "eb").AddEdge('b', "c");

            // asserst
            List <string> words = charsGraph.ComputeWords();

            CollectionAssert.Contains(words, "ae");
            CollectionAssert.Contains(words, "ea");

            CollectionAssert.Contains(words, "ab");
            CollectionAssert.Contains(words, "ba");

            CollectionAssert.Contains(words, "bc");
            CollectionAssert.Contains(words, "cb");

            CollectionAssert.Contains(words, "abc");
            CollectionAssert.Contains(words, "cba");

            CollectionAssert.Contains(words, "bae");
            CollectionAssert.Contains(words, "eab");

            CollectionAssert.Contains(words, "eabc");
            CollectionAssert.Contains(words, "cbae");
        }
Example #2
0
        public void AddEdge_MultiChars_Added()
        {
            // arrange
            CharsGraph charsGraph = new CharsGraph();

            // act
            charsGraph.AddEdge('a', "eb").AddEdge('b', "cde").AddEdge('c', "d").AddEdge('d', "e");

            // asserst
            string s = charsGraph.ToString();

            Assert.AreEqual("a:e,b;e:a,b,d;b:a,c,d,e;c:b,d;d:b,c,e;", s);
        }
Example #3
0
        public void AddEdge_3Chars_Added()
        {
            // arrange
            CharsGraph charsGraph = new CharsGraph();

            // act
            charsGraph.AddEdge('a', "eb").AddEdge('b', "c");

            // asserst
            string s = charsGraph.ToString();

            Assert.AreEqual("a:e,b;e:a;b:a,c;c:b;", s);
        }
Example #4
0
        public void ComputeWords_MultiChars_Computed()
        {
            // arrange
            CharsGraph charsGraph = new CharsGraph();

            // act
            charsGraph.AddEdge('a', "eb").AddEdge('b', "cde").AddEdge('c', "d").AddEdge('d', "e").AddEdge('e', "a");

            // asserst
            List <string> words = charsGraph.ComputeWords();

            Assert.AreEqual(25, words.Count);
        }
Example #5
0
        public void ComputeWords_3Chars_ComputedFiltered()
        {
            // arrange
            CharsGraph charsGraph = new CharsGraph(new List <string> {
                "cba", "ea"
            });

            // act
            charsGraph.AddEdge('a', "eb").AddEdge('b', "c");

            // asserst
            List <string> words = charsGraph.ComputeWords();

            Assert.AreEqual(2, words.Count);

            CollectionAssert.Contains(words, "cba");
            CollectionAssert.Contains(words, "ea");
        }