示例#1
0
        private void btnExecuteTest_Click(object sender, EventArgs e)
        {
            ofdFile.InitialDirectory = _testSutieFilesDir;

            if (ofdFile.ShowDialog() == DialogResult.OK)
            {
                var testSuite   = GetTestSuiteInfoFromTestSuiteFile(ofdFile.FileName);
                var testSummery = testSuite.TestSummery;

                var assertions = testSuite.TestCases.SelectMany(c => c.Assertions).ToList();
                _function = AbstractFunction.CreateInstance(testSuite.FunctionName);
                GenerateUnitTestFile(testSuite);

                foreach (var assertion in assertions)
                {
                    assertion.ActualOutput = _function.OriginalFunction(assertion.InputValues.ToArray());
                    assertion.Result       = assertion.ActualOutput == assertion.ExpectedOutput ? "Passed" : "Failed";
                }

                testSummery.Executed = assertions.Count;
                testSummery.Passed   = assertions.Count(a => a.Result == "Passed");
                testSummery.Failed   = assertions.Count(a => a.Result == "Failed");

                GenerateTestSuiteFile(testSuite);
            }
        }