Пример #1
0
        /// <summary>
        /// This method adds new event in the list.
        /// </summary>  
        /// <param name="testEvent">Test event.</param>
        public void AddEvent(TestEvent testEvent)
        {
            List<TestEvent> events = new List<TestEvent>();

            foreach (ListViewItem item in ItemsLV.Items)
            {
                events.Add((TestEvent)item.Tag);
            }

            events.Add(testEvent);

            this.BeginUpdate();

            for (int ii = 0; ii < events.Count; ii++)
            {
                AddItem(events[ii]);
            }

            EndUpdate();

            ItemsLV.Items[ItemsLV.Items.Count-1].EnsureVisible();
        }
Пример #2
0
        void TestClient_TestSequenceEvent(TestClient client, TestSequenceEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new TestSequenceEventHandler(TestClient_TestSequenceEvent), client, e);
                return;
            }
            
            try
            {
                if (e.TestCaseName == "Done")
                {
                    TestCancelMI.Enabled = false;

                    if (!m_client.Cancel)
                    {
                        if (m_endpointsToTest.Count > 0)
                        {
                            Connect(m_endpointsToTest.Dequeue(), m_currentOptions.UseAnsiCStack, m_currentOptions.KeySize);
                            return;
                        }

                        if (m_clientsToTest.Count > 0)
                        {
                            StartTest(m_clientsToTest.Dequeue());
                            return;
                        }
                    }

                    m_endpointsToTest.Clear();
                    m_clientsToTest.Clear();

                    TestEvent e1 = new TestEvent();

                    e1.Timestamp = DateTime.Now;
                    e1.TestId = 0;
                    e1.Iteration = 0;
                    e1.EventType = TestEventType.Completed;
                    e1.Details = Utils.Format("Completed all tests.");

                    TestEventsCTRL.AddEvent(e1);
                }

                TestCaseTB.Text  = e.TestCaseName;
                TestIdTB.Text    = String.Format("{0}", e.TestId);
                IterationTB.Text = String.Format("{0}", e.Iteration);
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }     
        }
Пример #3
0
        /// <summary>
        /// Connects to all endpoints.
        /// </summary>
        private void StartTest(ClientOptions options)
        {
            TestEvent e = new TestEvent();

            e.Timestamp = DateTime.Now;
            e.TestId = 0;
            e.Iteration = 0;
            e.EventType = TestEventType.Started;
            e.Details = Utils.Format("Testing with Client: {0}/{1}", (options.UseAnsiCStack)?"AnsiC":"DotNet", options.KeySize);

            this.TestEventsCTRL.AddEvent(e);

            m_currentOptions = options;
            m_endpointsToTest.Clear();

            foreach (ConfiguredEndpoint endpoint in m_endpoints.Endpoints)
            {
                if (options.UseAnsiCStack && endpoint.EndpointUrl.Scheme != Utils.UriSchemeOpcTcp)
                {
                    continue;
                }

                if (options.SerializersOnly && (endpoint.Description.SecurityMode != MessageSecurityMode.None || !endpoint.Description.EndpointUrl.EndsWith("1024")))
                {
                    continue;
                }

                m_endpointsToTest.Enqueue(endpoint);
            }

            if (m_endpointsToTest.Count > 0)
            {
                Connect(m_endpointsToTest.Dequeue(), options.UseAnsiCStack, options.KeySize);
            }
        }
Пример #4
0
        void TestClient_TestLogEventHandler(Logger logger, TestEvent e)
        {
            if (InvokeRequired)
            {
                Invoke(new TestLogEventHandler(TestClient_TestLogEventHandler), logger, e);
                return;
            }

            try
            {
                // TBD
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }     
        }
Пример #5
0
        /// <summary>
        /// Connects to a endpoint.
        /// </summary>
        private void Connect(ConfiguredEndpoint endpoint, bool useAnsiCStack, ushort keySize)
        {    
            try
            {
                TestEvent e = new TestEvent();

                e.Timestamp = DateTime.Now;
                e.TestId = 0;
                e.Iteration = 0;
                e.EventType = TestEventType.Started;
                e.Details = endpoint.ToString();

                this.TestEventsCTRL.AddEvent(e);

                CreateClient(useAnsiCStack, keySize);

                m_client.BeginExecuteTestSequence(endpoint);
                TestCancelMI.Enabled = true; 
            }
            catch (Exception exception)
            {
                MessageBox.Show("Connect");
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
                TestCancelMI.Enabled = false;
            }       
        }
Пример #6
0
        /// <summary>
        /// Logs stack events of an iteration
        /// </summary>
        /// <param name="stackEvents">List of stack events.</param>
        /// <param name="testCase">This parameter stores the test case related data.</param>
        /// <param name="iteration">This parameter stores the current iteration number.</param>
        public void LogStackEvents(List<StackEvent> stackEvents, TestCase testCase, int iteration)
        {
            if (stackEvents != null &&
                stackEvents.Count != 0 &&
                iteration != TestCases.TestSetupIteration &&
                iteration != TestCases.TestCleanupIteration
                )
            {
                StackEvent[] stackEventsArray = new StackEvent[stackEvents.Count];
                stackEvents.CopyTo(stackEventsArray);

                TestEvent testEvent = new TestEvent();
                testEvent.TestId = testCase.TestId;

                testEvent.Iteration = iteration;
                testEvent.EventType = TestEventType.StackEvents;
                testEvent.Timestamp = DateTime.UtcNow;
                testEvent.StackEvents = stackEventsArray;
                LogEvent(testEvent);
            }
        }
Пример #7
0
        /// <summary>
        /// Logs an event to the log.
        /// </summary>
        /// <param name="events">Test event.</param>
        public void LogEvent(TestEvent events)
        {
            lock (m_lock)
            {
                if (m_detailLevel == 0)
                {
                    return;
                }
                if (m_serializer == null || m_logger == null) return;

                m_serializer.Serialize(m_logger, events);

                if (m_TestLogEvent != null && events.EventType != TestEventType.StackEvents)
                {
                    m_TestLogEvent(this, events);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Logs an event when an error occurs during a test case.
        /// </summary>
        /// <param name="testCase">This parameter stores the test case related data.</param>
        /// <param name="iteration">This parameter stores the current iteration number.</param>
        /// <param name="e">Exception to be logged.</param>
        public void LogErrorEvent(TestCase testCase, int iteration, Exception e)
        {
            if ((m_detailLevel & TestLogDetailMasks.Errors) == 0)
            {
                return;
            }

            TestEvent events = new TestEvent();

            events.TestId = testCase.TestId;
            events.Timestamp = DateTime.UtcNow;
            events.Iteration = iteration;
            events.EventType = TestEventType.Failed;
            events.Details = new ServiceResult(e).ToLongString();

            LogEvent(events);
        }
Пример #9
0
        /// <summary>
        /// Logs an event when a test case completes sucessfully.
        /// </summary>
        /// <param name="testCase">This parameter stores the test case related data.</param>
        /// <param name="iteration">This parameter stores the current iteration number.</param>
        public void LogCompleteEvent(TestCase testCase, int iteration)
        {
            // the complete event can be logged each iteration or once per test case.
            if ((m_detailLevel & TestLogDetailMasks.AllsEnds) == 0)
            {
                if ((m_detailLevel & TestLogDetailMasks.LastEnd) == 0)
                {
                    return;
                }

                if (!TestUtils.IsSetupIteration(iteration))
                {
                    return;
                }
            }

            TestEvent events = new TestEvent();

            events.TestId = testCase.TestId;
            events.Timestamp = DateTime.UtcNow;
            events.Iteration = iteration;
            events.EventType = TestEventType.Completed;

            LogEvent(events);
        }