public static void AddParameterValue(QualityCondition qualityCondition,
                                             [NotNull] string parameterName,
                                             [CanBeNull] Dataset value,
                                             string filterExpression  = null,
                                             bool usedAsReferenceData = false)
        {
            Assert.ArgumentNotNullOrEmpty(parameterName, nameof(parameterName));

            TestFactory factory =
                TestFactoryUtils.GetTestFactory(qualityCondition.TestDescriptor);

            TestParameter parameter = Assert.NotNull(factory).GetParameter(parameterName);

            TestParameterTypeUtils.AssertValidDataset(parameter, value);
            var parameterValue = new DatasetTestParameterValue(parameter, value,
                                                               filterExpression,
                                                               usedAsReferenceData);

            parameterValue.DataType = parameter.Type;
            qualityCondition.AddParameterValue(parameterValue);
        }
        private static void AddScalarParameterValue(QualityCondition qualityCondition,
                                                    [NotNull] string parameterName,
                                                    [CanBeNull] object value)
        {
            Assert.ArgumentNotNullOrEmpty(parameterName, nameof(parameterName));

            TestFactory factory =
                TestFactoryUtils.GetTestFactory(qualityCondition.TestDescriptor);

            TestParameter parameter = Assert.NotNull(factory).GetParameter(parameterName);

            if (!parameter.IsConstructorParameter && parameter.Type.IsValueType &&
                (value == null || value as string == string.Empty))
            {
                return;
            }

            var parameterValue = new ScalarTestParameterValue(parameter, value);

            parameterValue.DataType = parameter.Type;
            qualityCondition.AddParameterValue(parameterValue);
        }
Esempio n. 3
0
        public QualityCondition Convert([NotNull] Matrix matrix,
                                        [NotNull] IList <Dataset> datasets)
        {
            Assert.ArgumentNotNull(matrix, nameof(matrix));
            Assert.ArgumentNotNull(datasets, nameof(datasets));

            var classDescriptor = new ClassDescriptor(typeof(QaTopoNotNearPolyFactory));

            var testDescriptor = new TestDescriptor(
                _importedTestDescriptor, classDescriptor);

            var qualityCondition = new QualityCondition(
                _importedQualityCondition, testDescriptor);

            Dictionary <string, TestParameter> parDict = QaTopoNotNearPolyFactory
                                                         .CreateParameterList()
                                                         .ToDictionary(x => x.Name);

            VectorDataset featureClassDs = GetDataset(matrix.FeatureClassName, datasets);

            qualityCondition.AddParameterValue(new DatasetTestParameterValue(
                                                   parDict[
                                                       QaTopoNotNearPolyFactory
                                                       .FeatureClassParamName], featureClassDs)
            {
                FilterExpression = matrix.FeatureClassFilter
            });
            VectorDataset referenceDs = GetDataset(matrix.ReferenceName, datasets);

            qualityCondition.AddParameterValue(new DatasetTestParameterValue(
                                                   parDict[
                                                       QaTopoNotNearPolyFactory.ReferenceParamName],
                                                   referenceDs)
            {
                FilterExpression = matrix.ReferenceFilter
            });

            {
                GetSubtypes(featureClassDs, out string field, out IList <Subtype> subtypes);
                Assert.NotNull(field);
                Assert.NotNull(subtypes);

                foreach (FeatureTypeProps featureTypeProps in matrix.FeatureClassTypes)
                {
                    string  subtypeName = featureTypeProps.SubType.SubtypeName.Trim();
                    Subtype subtype     = subtypes.First(x => x.Name.Equals(subtypeName));

                    StringBuilder rulesBuilder = new StringBuilder();
                    rulesBuilder.Append($"{subtype.Code};");
                    rulesBuilder.Append($"{featureTypeProps.DefaultDistance};");
                    rulesBuilder.Append($"{featureTypeProps.RightSideDistance};");
                    foreach (int canOverlap in featureTypeProps.CanOverlap)
                    {
                        rulesBuilder.Append($"{canOverlap};");
                    }

                    qualityCondition.AddParameterValue(new ScalarTestParameterValue(
                                                           parDict[
                                                               QaTopoNotNearPolyFactory
                                                               .FeaturesubtypeRulesParamName],
                                                           rulesBuilder.ToString()));
                }
            }
            {
                GetSubtypes(referenceDs, out string field, out IList <Subtype> subtypes);
                Assert.NotNull(field);
                Assert.NotNull(subtypes);

                foreach (ConnectionType refType in matrix.ReferenceTypes)
                {
                    string  subtypeName = refType.SubtypeName.Trim();
                    Subtype subtype     = subtypes.First(x => x.Name.Equals(subtypeName));
                    qualityCondition.AddParameterValue(new ScalarTestParameterValue(
                                                           parDict[
                                                               QaTopoNotNearPolyFactory
                                                               .ReferenceSubtypesParamName],
                                                           subtype.Code));
                }
            }

            return(qualityCondition);
        }