public void Test_Generic(string list, int pos) { var head = ListNodeHelper.BuildList(list); var expected = head; if (pos == -1) { expected = null; } else { for (int i = 0; i < pos; i++) { expected = expected.next; } ListNodeHelper.Tail(head).next = expected; } var sol = new Solution(); var res = sol.DetectCycle(head); Assert.AreEqual(res, expected); }