/// <summary>
        /// Parse and verify a capture file.
        /// </summary>
        /// <param name="captureFilePath">Specifies the path of the capture file.</param>
        /// <param name="saveResult">Specifies whether to save the result or not. If true, save the captured messages and selected messages. If false, don't save.</param>
        public void ParseAndVerify(string captureFilePath, bool saveResult = false)
        {
            // Make sure the expected Sequence has been loaded
            this.site.Log.Add(LogEntryKind.Comment, "MessageAnalyzerAdapter.StartCapture: Make sure the expected Sequence has been loaded.");
            LoadExpectedSequence();

            // If monitor is not created, create a new monitor.
            if (monitor == null)
            {
                monitor = MessageAnalyzerMonitor.CreateMonitor(null, true);
            }

            // Create fileCapture from a capture file
            fileCapture = (CaptureFileSession)monitor.CreateCaptureFileSession(captureFilePath);

            // Add verify process to onNewMessageEvent and start the capture
            fileCapture.Start(filter);

            // Wait until parse completed
            fileCapture.WaitUntilParsingComplete();

            // Stop the capture
            fileCapture.Stop();

            VerifyMessageSequence(fileCapture);

            if (saveResult)
            {
                fileCapture.SaveCapturedMessages(capturedMessagesSavePath);
            }
        }
예제 #2
0
        /// <summary>
        /// Parse and verify a capture file
        /// </summary>
        /// <param name="captureFilePath">Path of the capture file</param>
        /// <param name="saveResult">If true, save the captured messages and selected messages. If false, don't save</param>
        public bool ParseAndVerify(string captureFilePath, bool saveResult = false)
        {
            // Make sure the expected Sequence has been loaded
            this.site.Log.Add(LogEntryKind.Comment, "MessageAnalyzerAdapter.StartCapture: Make sure the expected Sequence has been loaded");
            LoadExpectedSequence();

            // If monitor is not created, create a new monitor.
            if (monitor == null)
            {
                monitor = MessageAnalyzerMonitor.CreateMonitor(null, true);
            }

            // Create fileCapture from a capture file
            fileCapture = (CaptureFileSession)monitor.CreateCaptureFileSession(captureFilePath);

            // Add verify process to onNewMessageEvent and start the capture
            fileCapture.Start(filter);

            // Wait until parse completed
            fileCapture.WaitUntilParsingComplete();

            // Stop the capture
            fileCapture.Stop();

            bool isSuccess = VerifyMessageSequence(fileCapture);

            if (saveResult)
            {
                // Save messages if saveResult is true
                if (capturedMessagesSavePath != null)
                {
                    fileCapture.SaveCapturedMessages(capturedMessagesSavePath);
                }
                if (selectedMessagesSavePath != null)
                {
                    fileCapture.SaveCapturedMessages(selectedMessagesSavePath);
                }
            }

            if (isSuccess)
            {
                this.site.Log.Add(LogEntryKind.Comment, "MessageAnalyzerAdapter verify stopped. The capture matches the expected sequences.");
            }
            else
            {
                this.site.Log.Add(LogEntryKind.Comment, "MessageAnalyzerAdapter verify stopped. The capture doesn't match the expected sequences.");
            }

            return(isSuccess);
        }
        /// <summary>
        /// Get Messages with filter applied to the capture
        /// </summary>
        /// <param name="capturePath">The capture file path</param>
        /// <param name="frameFilter">The filter applied to the capture</param>
        /// <returns>Return the filtered messages</returns>
        public List <Message> GetMessages(string capturePath, string frameFilter)
        {
            // If monitor is not created, create a new monitor.
            if (monitor == null)
            {
                monitor = MessageAnalyzerMonitor.CreateMonitor(null, true);
            }

            // Create fileCapture from a capture file
            fileCapture = (CaptureFileSession)monitor.CreateCaptureFileSession(capturePath);

            // Add verify process to onNewMessageEvent and start the capture
            fileCapture.Start(frameFilter);

            // Wait until parse completed
            fileCapture.WaitUntilParsingComplete();

            // Stop the capture
            fileCapture.Stop();

            return(fileCapture.SortedMessagesWithOperationChildrenList.ToList <Message>());
        }