コード例 #1
0
        public void threeSumTest()
        {
            foreach (ThreeSumTestData testData in TestDataList)
            {
                Console.WriteLine("Testing => Input: [{0}]", string.Join(", ", testData.InputArray));


                IList <IList <int> > result = ThreeSum.threeSum(testData.InputArray);

                int i = 0;
                while ((testData.OutputList.Count == result.Count) && (i < result.Count) && (i < testData.OutputList.Count))
                {
                    Console.WriteLine("Result set " + (i + 1) + " :");
                    Console.Write("Expected output: ");
                    foreach (var output in testData.OutputList[i])
                    {
                        Console.Write(output + ", ");
                    }
                    Console.WriteLine();

                    Console.Write("Actual output: ");
                    foreach (var output in result[i])
                    {
                        Console.Write(output + ", ");
                    }
                    Console.WriteLine();

                    CollectionAssert.AreEqual((List <int>)result[i], (List <int>)testData.OutputList[i],
                                              "result sets are not equal");
                    i++;
                }
            }
        }