示例#1
0
        public void Q02Permutation()
        {
            var q = new Question02();

            Assert.IsTrue(q.ArePermutations("", ""));
            Assert.IsTrue(q.ArePermutations("ab", "ba"));
            Assert.IsTrue(q.ArePermutations("dog", "god"));

            Assert.IsFalse(q.ArePermutations("ab", "bb"));
            Assert.IsFalse(q.ArePermutations("a", ""));
        }
示例#2
0
        public void Question02ShouldThrowArgumentException()
        {
            var linkedList = new LinkedList <int>();

            linkedList.AppendToTail(1);
            linkedList.AppendToTail(2);
            linkedList.AppendToTail(3);
            linkedList.AppendToTail(4);
            linkedList.AppendToTail(5);

            Assert.Throws <ArgumentException>(
                () => (Question02 <int> .GetNthToLastElement(linkedList, 6))
                );
        }
示例#3
0
        public void Question02ShouldGetNthToLastElement()
        {
            var linkedList = new LinkedList <int>();

            linkedList.AppendToTail(1);
            linkedList.AppendToTail(2);
            linkedList.AppendToTail(3);
            linkedList.AppendToTail(4);
            linkedList.AppendToTail(5);

            Node <int> expected = linkedList.Head.Next.Next.Next;            // 4

            Node <int> actual = Question02 <int> .GetNthToLastElement(linkedList, 2);

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void Question02ShouldFindPalindromes()
        {
            string input = "Test! aabbaa ccc";

            var expected = new List <string>();

            int expectedSize = 2;

            string expected1 = " aabbaa ";
            string expected2 = "ccc";

            expected.Add(expected1);
            expected.Add(expected2);

            List <string> actual = Question02.FindPalindromes(input);

            Assert.Equal(expectedSize, actual.Count);
            Assert.Contains(expected1, actual);
            Assert.Contains(expected2, actual);
        }
示例#5
0
 public void Question02ShouldReverseAString()
 {
     Assert.Equal("dcba", Question02.Reverse("abcd"));
 }