private void OnProgress([NotNull] VerificationProgressEventArgs args)
        {
            TestExecutionUtils.LogProgress(args);

            if (Progress != null)
            {
                if (args.CurrentBox != null && _testPerimeter != null)
                {
                    args.SetSpatialReference(_testPerimeter.SpatialReference);
                }

                Progress(this, args);
            }
        }
        private bool TryReportStopInfo(
            [NotNull] StopInfo stopInfo,
            [NotNull] IRow row,
            [NotNull] QualityConditionVerification qualityConditionVerification)
        {
            Assert.ArgumentNotNull(stopInfo, nameof(stopInfo));
            Assert.ArgumentNotNull(row, nameof(row));
            Assert.ArgumentNotNull(qualityConditionVerification,
                                   nameof(qualityConditionVerification));

            qualityConditionVerification.StopCondition = stopInfo.QualityCondition;
            QualityCondition stoppedCondition = qualityConditionVerification.QualityCondition;

            Assert.NotNull(stoppedCondition, "stoppedCondition");

            // TODO gather all stopped conditions for the row, report at end
            // https://issuetracker02.eggits.net/browse/COM-248
            IGeometry errorGeom = TestUtils.GetShapeCopy(row);

            IList <ITest> stoppedTests = _testsByCondition[stoppedCondition];

            string description =
                TestExecutionUtils.GetStopInfoErrorDescription(stopInfo);

            foreach (ITest stoppedTest in stoppedTests)
            {
                // TODO add issue code
                var error = new QaError(stoppedTest, description,
                                        new[] { new InvolvedRow(row) },
                                        errorGeom, null, null);
                bool reported = ProcessQaError(error);

                if (reported)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void EndVerification(QualityVerification qualityVerification,
                                     TimeSpan startTime)
        {
            if (qualityVerification == null)
            {
                return;
            }

            TimeSpan endTime = Process.GetCurrentProcess().UserProcessorTime;

            TimeSpan t = endTime - startTime;

            qualityVerification.ProcessorTimeSeconds = t.TotalSeconds;

            qualityVerification.EndDate = DateTime.Now;

            qualityVerification.Cancelled = Cancelled;
            qualityVerification.CalculateStatistics();
            qualityVerification.RowsWithStopConditions = RowsWithStopConditions.Count;

            TestExecutionUtils.AssignExecutionTimes(
                qualityVerification, _testVerifications, VerificationTimeStats,
                Assert.NotNull(DatasetLookup));
        }
        private void Verify([NotNull] TestContainer container,
                            [CanBeNull] AreaOfInterest areaOfInterest)
        {
            Assert.ArgumentNotNull(container, nameof(container));

            ClearCurrentRow();

            // add handlers
            container.TestingRow      += container_TestingRow;
            container.QaError         += HandleError;
            container.ProgressChanged += container_OnProgressChanged;

            try
            {
                _executeContainer = container;

                // TODO let the container know about the selected features
                // (filter TestRows by inclusion in selection list)

                TestExecutionUtils.Execute(container, areaOfInterest);
            }
            catch (TestContainerException e)
            {
                QualityCondition qualityCondition = GetQualityCondition(e.Test);

                string description = string.Format("Error testing {0}: {1}",
                                                   qualityCondition.Name,
                                                   e.Message);

                var       involvedRows           = new InvolvedRow[] { };
                IGeometry exceptionErrorGeometry = null;

                if (_currentRow != null)
                {
                    if (_currentRow.HasOID && _currentRow.Table.HasOID)
                    // ie TerrainRow (wrapper around terrain tile)
                    {
                        // second part: ESRI Bug for IQueryDefTables
                        // which returns row.HasOID = true
                        involvedRows = new[] { new InvolvedRow(_currentRow) };
                    }

                    try
                    {
                        var feature = _currentRow as IFeature;

                        IGeometry shape = feature?.Shape;
                        if (shape != null && !shape.IsEmpty)
                        {
                            exceptionErrorGeometry = feature.ShapeCopy;
                        }
                    }
                    catch (Exception exception)
                    {
                        _msg.Error(
                            "Error trying to get geometry from feature involved in failed test",
                            exception);
                    }
                }

                if (exceptionErrorGeometry == null)
                {
                    exceptionErrorGeometry = e.Box;
                }

                var qaError = new QaError(e.Test, description, involvedRows,
                                          exceptionErrorGeometry, null, null);

                ProcessQaError(qaError);

                CancellationTokenSource.Cancel();
                CancellationMessage = description;
                _msg.Error(description, e);
            }
            finally
            {
                // remove handlers
                container.ProgressChanged -= container_OnProgressChanged;
                container.QaError         -= HandleError;
                container.TestingRow      -= container_TestingRow;
            }
        }