Beispiel #1
0
        public void TestEmptyListE()
        {
            af = new AnagramFinder();
            List <List <String> > emptyListE = af.FindAllAnagramsWithDuplicateLetters(new List <String>());

            Assert.AreEqual(0, emptyListE.Count);
        }
Beispiel #2
0
        public void TestNoAnagrams()
        {
            af = new AnagramFinder();
            List <String> list = new List <String> {
                "bee", "ebbc"
            };

            Assert.AreEqual(1, af.FindAllAnagramsWithDuplicateLetters(list).Count);
        }
Beispiel #3
0
        public void TestSingleWord()
        {
            af = new AnagramFinder();
            List <String> list = new List <String> {
                "fish"
            };

            Assert.AreEqual(0, af.FindAllAnagramsWithDuplicateLetters(list).Count);
        }
Beispiel #4
0
        public void TestNullListE()
        {
            af = new AnagramFinder();

            var actual = Assert.ThrowsException <ArgumentException>(() =>
                                                                    af.FindAllAnagramsWithDuplicateLetters(null));

            Assert.AreEqual(actual.Message, "Param 'wordList' is null or empty");
        }
Beispiel #5
0
        public void TestCaseInsensitive()
        {
            af = new AnagramFinder();
            List <String> l = new List <String> {
                "SILENT", "listen", "taLent", "LatenT"
            };
            List <List <String> > actual = af.FindAllAnagramsWithDuplicateLetters(l);
            String expected = "[[LatenT, taLent], [listen, SILENT]]";

            Assert.AreEqual(expected, actual.ToString());
        }
Beispiel #6
0
        public void TestEmptyValE()
        {
            af = new AnagramFinder();
            List <String> emptyValL = new List <String> {
                "dale", "vale", "veal", "", "lead"
            };

            var actual = Assert.ThrowsException <ArgumentException>(() =>
                                                                    af.FindAllAnagramsWithDuplicateLetters(emptyValL));

            Assert.AreEqual("Param 'wordList' contains null or empty val", actual.Message);
        }
        public void TestCaseInsensitive()
        {
            af = new AnagramFinder();
            List <String> l = new List <String> {
                "SILENT", "listen", "taLent", "LatenT"
            };
            List <List <String> > actualL = af.FindAllAnagramsWithDuplicateLetters(l);
            String expected = "LatenT, taLent, listen, SILENT";
            String actualS  = "";

            actualL.ForEach(y => y.ForEach(x => actualS += (x + ", ")));
            actualS = actualS.Substring(0, actualS.Length - 2);
            Assert.AreEqual(expected, actualS);
        }
Beispiel #8
0
        public void TestIgnoreDuplicate()
        {
            af = new AnagramFinder();
            List <String> list = new List <String> {
                "lead", "silent", "dale", "talent", "new york times", "vile", "talent", "deal", "listen", "monkeys write", "evil"
            };
            List <List <String> > test   = af.FindAllAnagramsWithDuplicateLetters(list);
            List <String>         actual = new List <String>();

            foreach (List <String> sl in test)
            {
                actual.AddRange(sl);
            }
            Assert.IsTrue(list.Count > actual.Count);
        }
Beispiel #9
0
        public void TestReturns()
        {
            af = new AnagramFinder();

            List <String> list = new List <String> {
                "lead", "silent", "dale", "talent", "new york times", "vile", "deal", "listen", "monkeys write", "evil"
            };
            List <String> expected = new List <String>();

            foreach (List <String> sList in af.FindAllAnagramsWithDuplicateLetters(list))
            {
                expected.Add(sList[0]);
                sList.Should().BeInAscendingOrder();
            }
            expected.Should().BeInAscendingOrder();
        }
Beispiel #10
0
        public void TestTwoWords()
        {
            af = new AnagramFinder();

            List <String> list = new List <String> {
                "bee", "ebb"
            };
            List <List <String> > actual = af.FindAllAnagramsWithDuplicateLetters(list);

            Assert.AreEqual(1, actual.Count);

            foreach (List <String> l in actual)
            {
                l.Should().BeInAscendingOrder();
            }
        }