예제 #1
0
파일: RunForm.cs 프로젝트: zxscn/ReoGrid
        void Instance_AfterPerformTestCase(object sender, TestCaseEventArgs e)
        {
            ListViewItem item = GetItemByTestSetInfo(e.TestSetInfo);

            item.SubItems[3].Text = string.Format("{0} ms.", e.TestCaseInfo.ElapsedMilliseconds);
            item.SubItems[4].Text = string.Format("{0} KB", (e.TestCaseInfo.MemoryUsage / 1024).ToString("###,###,##0"));

            Exception ex = e.TestCaseInfo.Exception;

            if (ex != null)
            {
                item.SubItems[2].Text = "Failed: " + ex.Message;
                item.ImageIndex       = 2;

                exceptionBuffer.AppendLine(ex.ToString());
                exceptionBuffer.AppendLine();

                grid.Show();

                cellDebug.Show();
                cellDebug.Location = new Point(this.Right + 1, this.Top + 1);
                borderDebug.Show();
                borderDebug.Location = new Point(this.Right + 1, cellDebug.Bottom + 1);
            }
            else if (item.ImageIndex != 2)
            {
                item.SubItems[2].Text = "Success";
                item.ImageIndex       = 1;
            }

            Application.DoEvents();
        }
예제 #2
0
        internal bool RunTestCase(TestSetInfo testSetInfo, TestCaseInfo testCaseInfo, List <string> failList)
        {
            object testSet = testSetInfo.Instance;

            stop.Reset();

            if (BeforePerformTestCase != null)
            {
                var evtArg = new TestCaseEventArgs(testSetInfo, testCaseInfo);
                BeforePerformTestCase(this, evtArg);
                if (evtArg.Cancel)
                {
                    return(true);
                }
            }

            GC.Collect(0, GCCollectionMode.Forced);
            long mem = GetProcessMemoryUsage();

            stop.Start();

            try
            {
                testCaseInfo.Method.Invoke(testSet, null);
            }
            catch (TargetInvocationException x)
            {
                testCaseInfo.Exception = x.InnerException;
                if (failList != null)
                {
                    failList.Add(testSetInfo.Name + "." + testCaseInfo.Name);
                }
            }
            catch (TestCaseFailureException x)
            {
                testCaseInfo.Exception = x;
                if (failList != null)
                {
                    failList.Add(testSetInfo.Name + "." + testCaseInfo.Name);
                }
            }

            stop.Stop();

            testCaseInfo.Performed           = true;
            testCaseInfo.ElapsedMilliseconds = stop.ElapsedMilliseconds;
            testCaseInfo.MemoryUsage         = GetProcessMemoryUsage() - mem;

            GC.Collect(0, GCCollectionMode.Forced);

            if (AfterPerformTestCase != null)
            {
                AfterPerformTestCase(this, new TestCaseEventArgs(testSetInfo, testCaseInfo));
            }

            return(testCaseInfo.Exception != null);
        }
예제 #3
0
 void Instance_AfterPerformTestCase(object sender, TestCaseEventArgs e)
 {
     Console.WriteLine(string.Format("{0} ( {1,4} ms. {2,8} kb. )",
                                     (e.TestCaseInfo.Exception != null ? e.TestCaseInfo.ToString() : "passed"),
                                     e.TestCaseInfo.ElapsedMilliseconds, (e.TestCaseInfo.MemoryUsage / 1024).ToString("###,###,##0")));
     if (e.TestCaseInfo.Exception != null)
     {
         Console.WriteLine("    " + e.TestCaseInfo.Exception.ToString());
     }
 }
예제 #4
0
파일: RunForm.cs 프로젝트: zxscn/ReoGrid
        void Instance_BeforePerformTestCase(object sender, TestCaseEventArgs e)
        {
            bool showGrid = false;

            if (e.TestSetInfo.Instance is ReoGridTestSet)
            {
                ((ReoGridTestSet)e.TestSetInfo.Instance).Grid = grid;

                if (((ReoGridTestSet)e.TestSetInfo.Instance).ShowControl)
                {
                    showGrid = true;
                }
            }

            grid.Visible = showGrid;

            var listNode = GetItemByTestSetInfo(e.TestSetInfo);

            e.Cancel = listNode == null || !listNode.Checked;
        }
예제 #5
0
 void Instance_BeforePerformTestCase(object sender, TestCaseEventArgs e)
 {
     Console.Write(string.Format("    {0,-38}... ", e.TestCaseInfo.Name));
 }