public void TestMethod1()
        {
            var Input = new string[] { "eat", "tea", "tan", "ate", "nat", "bat" };
            IList <IList <string> > Expected = new List <IList <string> >()
            {
                new List <string> {
                    "ate", "eat", "tea"
                },
                new List <string> {
                    "nat", "tan"
                },
                new List <string> {
                    "bat"
                }
            };
            var Actual = GroupAnagrams_49.GroupAnagrams(Input);

            Assert.AreEqual(Expected.Count, Actual.Count);
            for (int i = 0; i < Expected.Count; i++)
            {
                for (int j = 0; j < Expected[i].Count; j++)
                {
                    CollectionAssert.Contains(Expected[i].ToList(), Actual[i][j]);
                }
            }
        }
Exemplo n.º 2
0
        public void Test()
        {
            GroupAnagrams_49        g     = new GroupAnagrams_49();
            IList <IList <string> > lists = g.GroupAnagrams(new[] { "eat", "tea", "tan", "ate", "nat", "bat" });

            Assert.Equal(3, lists.Count);

            IList <string> list1 = lists.Single(o => o.Count == 3);

            Assert.Contains("eat", list1);
            Assert.Contains("ate", list1);
            Assert.Contains("tea", list1);

            IList <string> list2 = lists.Single(o => o.Count == 2);

            Assert.Contains("nat", list2);
            Assert.Contains("tan", list2);

            IList <string> list3 = lists.Single(o => o.Count == 1);

            Assert.Contains("bat", list3);
        }