예제 #1
0
        private void lstTests_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            KeyValuePair <TestClass, MethodInfoEx> kvTc = (KeyValuePair <TestClass, MethodInfoEx>)e.Item.Tag;
            MethodInfoEx mi = kvTc.Value;

            mi.Enabled = e.Item.Checked;
        }
예제 #2
0
        public void SaveToDatabase(TestClass tc, MethodInfoEx mi, Exception err = null)
        {
            using (TestingEntities entities = TestEntitiesConnection.CreateEntities())
            {
                List <Session> rgSessions = entities.Sessions.Where(p => p.Session1 == m_strName).ToList();

                if (rgSessions.Count > 0)
                {
                    int         nSessionID = rgSessions[0].ID;
                    List <Test> rgTest     = entities.Tests.Where(p => p.SessionID == nSessionID && p.TestGroup == tc.Name && p.TestMethod == mi.Name).ToList();

                    if (rgTest.Count > 0)
                    {
                        if (err != null)
                        {
                            rgTest[0].ErrorString   = getString(err.Message, 1023);
                            rgTest[0].ErrorLocation = getString(err.StackTrace, 1023);
                        }

                        rgTest[0].Success = (mi.Status == MethodInfoEx.STATUS.Passed) ? true : false;
                        decimal dTiming = Math.Min(9999999, (decimal)mi.TestTiming.TotalMilliseconds);
                        rgTest[0].TestTiming = dTiming;

                        entities.SaveChanges();
                    }
                }
            }
        }
예제 #3
0
        public void UpdateStatus()
        {
            foreach (ListViewItem lvi in lstTests.Items)
            {
                KeyValuePair <TestClass, MethodInfoEx> kvTc = (KeyValuePair <TestClass, MethodInfoEx>)lvi.Tag;
                MethodInfoEx mi = kvTc.Value;

                if (lvi.ImageIndex != (int)mi.Status)
                {
                    lvi.SubItems[1].Text = mi.Status.ToString();
                    lvi.ImageIndex       = (int)mi.Status;

                    if (mi.Status == MethodInfoEx.STATUS.Passed)
                    {
                        lvi.Checked = false;
                        mi.Enabled  = false;
                    }

                    if (mi.Status == MethodInfoEx.STATUS.Running)
                    {
                        lvi.EnsureVisible();
                    }
                }

                if (mi.ErrorInfo.Error != null && lvi.SubItems[4].Text.Length == 0)
                {
                    lvi.SubItems[4].Text = mi.ErrorInfo.ShortErrorString;
                    lvi.SubItems[4].Tag  = mi.ErrorInfo;
                }
            }
        }
예제 #4
0
        public void UpdateStatus()
        {
            int          nProgressCount = 0;
            MethodInfoEx miLast         = null;

            foreach (ListViewItem lvi in lstTests.Items)
            {
                KeyValuePair <TestClass, MethodInfoEx> kvTc = (KeyValuePair <TestClass, MethodInfoEx>)lvi.Tag;
                MethodInfoEx mi = kvTc.Value;

                if (lvi.ImageIndex != (int)mi.Status)
                {
                    lvi.SubItems[1].Text = mi.Status.ToString();
                    lvi.ImageIndex       = (int)mi.Status;

                    if (mi.Status == MethodInfoEx.STATUS.Passed)
                    {
                        lvi.Checked = false;
                        mi.Enabled  = false;
                    }

                    if (mi.Status == MethodInfoEx.STATUS.Running)
                    {
                        lvi.EnsureVisible();
                    }
                }

                double?dfProgress = mi.Progress;
                if (!dfProgress.HasValue)
                {
                    dfProgress = m_progress.GetProgress();
                }

                if (dfProgress.HasValue)
                {
                    nProgressCount++;
                    tsItemProgress.Visible = true;
                    pbItemProgress.Visible = true;
                    tsItemProgress.Text    = dfProgress.Value.ToString("P");
                    pbItemProgress.Value   = (int)(dfProgress.Value * 100.0);
                }

                if (mi.ErrorInfo.Error != null && lvi.SubItems[4].Text.Length == 0)
                {
                    lvi.SubItems[4].Text = mi.ErrorInfo.ShortErrorString;
                    lvi.SubItems[4].Tag  = mi.ErrorInfo;
                }

                miLast = mi;
            }

            if (nProgressCount == 0)
            {
                tsItemProgress.Visible = false;
                pbItemProgress.Visible = false;
            }
        }
예제 #5
0
        public void InvokeMethod(string strName)
        {
            MethodInfoEx mi = m_rgMethods.Find(strName);

            if (mi != null && mi.Enabled)
            {
                if (m_instance == null)
                {
                    m_instance = Activator.CreateInstance(m_type, null);
                }
                mi.MethodInfo.Invoke(m_instance, null);
            }
        }
예제 #6
0
        private void resetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in lstTests.SelectedItems)
            {
                KeyValuePair <TestClass, MethodInfoEx> kvTc = (KeyValuePair <TestClass, MethodInfoEx>)lvi.Tag;
                MethodInfoEx mi = kvTc.Value;

                mi.Enabled = true;
                mi.Status  = MethodInfoEx.STATUS.NotExecuted;

                lvi.Checked          = true;
                lvi.SubItems[4].Text = "";
                lvi.SubItems[4].Tag  = null;
            }
        }
예제 #7
0
        private void setInitialSettings()
        {
            if (m_rgKnownFailures == null)
            {
                return;
            }

            foreach (Tuple <string, string, string> knownFailure in m_rgKnownFailures)
            {
                TestClass testClass = Find(knownFailure.Item1);
                if (testClass != null)
                {
                    MethodInfoEx mi = testClass.Methods.Find(knownFailure.Item2);
                    if (mi != null)
                    {
                        mi.Status = MethodInfoEx.STATUS.Failed;
                        mi.ErrorInfo.SetError(new Exception(knownFailure.Item3));
                    }
                }
            }
        }
예제 #8
0
        private void testThread(object obj)
        {
            Tuple <AutoResetEvent, bool, bool> param = obj as Tuple <AutoResetEvent, bool, bool>;
            AutoResetEvent evtCancel   = param.Item1;
            bool           bSkip       = param.Item2;
            bool           bServerMode = param.Item3;
            TestClass      tcCurrent   = null;
            MethodInfoEx   miCurrent   = null;

            m_nCurrentTest = 0;
            m_swTiming.Reset();
            m_swTiming.Start();

            try
            {
                foreach (TestClass tc in m_rgClasses)
                {
                    tcCurrent = tc;

                    foreach (MethodInfoEx mi in tc.Methods)
                    {
                        miCurrent = mi;

                        if (evtCancel.WaitOne(0))
                        {
                            return;
                        }

                        if (mi.Enabled && (!bServerMode || mi.Status == MethodInfoEx.STATUS.NotExecuted))
                        {
                            m_strCurrentTest = tc.Name + "::" + mi.Name;

                            if (bSkip)
                            {
                                mi.ErrorInfo.SetError(new Exception("SKIPPED"));
                                mi.Status = MethodInfoEx.STATUS.Failed;
                            }
                            else
                            {
                                mi.Invoke(tc.Instance);
                            }

                            if (mi.Status != MethodInfoEx.STATUS.Aborted)
                            {
                                SaveToDatabase(tc, mi);
                            }
                        }

                        m_nCurrentTest++;
                    }
                }
            }
            catch (Exception excpt)
            {
                SaveToDatabase(tcCurrent, miCurrent, excpt);
                tcCurrent.InvokeDispose();

                throw excpt;
            }
            finally
            {
                m_swTiming.Stop();

                if (OnRunCompleted != null)
                {
                    OnRunCompleted(this, new EventArgs());
                }
            }
        }
예제 #9
0
        private void testThread(object obj)
        {
            Tuple <AutoResetEvent, bool, bool, int> param = obj as Tuple <AutoResetEvent, bool, bool, int>;
            AutoResetEvent evtCancel   = param.Item1;
            bool           bSkip       = param.Item2;
            bool           bServerMode = param.Item3;
            int            nGpuId      = param.Item4;
            TestClass      tcCurrent   = null;
            MethodInfoEx   miCurrent   = null;


            m_nCurrentTest = 0;
            m_swTiming.Reset();
            m_swTiming.Start();

            string strSrcStart  = "MyCaffe Automated Test Start";
            string strSrcResult = "MyCaffe Automated Test Result";
            string strLog       = "Application";

            EventLog eventLogStart = new EventLog(strLog);

            eventLogStart.Source = strSrcStart;

            EventLog eventLogResult = new EventLog(strLog);

            eventLogResult.Source = strSrcResult;

            try
            {
                foreach (TestClass tc in m_rgClasses)
                {
                    tcCurrent = tc;

                    foreach (MethodInfoEx mi in tc.Methods)
                    {
                        miCurrent = mi;

                        if (evtCancel.WaitOne(0))
                        {
                            return;
                        }

                        if (mi.Enabled && (!bServerMode || mi.Status == MethodInfoEx.STATUS.NotExecuted))
                        {
                            m_strCurrentTest = tc.Name + "::" + mi.Name;

                            if (bSkip)
                            {
                                mi.ErrorInfo.SetError(new Exception("SKIPPED"));
                                mi.Status = MethodInfoEx.STATUS.Failed;
                            }
                            else
                            {
                                eventLogStart.WriteEntry("Starting " + tc.Name + "::" + mi.Name + " test.");

                                mi.Invoke(tc.Instance, nGpuId);

                                if (mi.Status == MethodInfoEx.STATUS.Failed)
                                {
                                    eventLogResult.WriteEntry("ERROR " + tc.Name + "::" + mi.Name + " test - " + mi.Status.ToString() + " Error Information: " + mi.ErrorInfo.FullErrorString, EventLogEntryType.Warning);
                                }
                                else
                                {
                                    eventLogResult.WriteEntry("Completed " + tc.Name + "::" + mi.Name + " test - " + mi.Status.ToString(), EventLogEntryType.Information);
                                }
                            }

                            if (mi.Status != MethodInfoEx.STATUS.Aborted)
                            {
                                SaveToDatabase(tc, mi);
                            }
                        }

                        m_nCurrentTest++;
                    }
                }
            }
            catch (Exception excpt)
            {
                SaveToDatabase(tcCurrent, miCurrent, excpt);
                tcCurrent.InvokeDispose();

                eventLogStart.WriteEntry("Test Exception Thrown! " + excpt.Message, EventLogEntryType.Error);

                throw excpt;
            }
            finally
            {
                m_swTiming.Stop();

                if (OnRunCompleted != null)
                {
                    OnRunCompleted(this, new EventArgs());
                }

                eventLogStart.Close();
                eventLogResult.Close();
            }
        }