示例#1
0
        public void CanCreateEmptyQualitySpecification()
        {
            var xmlQualitySpecification = new XmlQualitySpecification {
                Name = "Empty"
            };

            var xmlDocument = new XmlDataQualityDocument();

            xmlDocument.AddQualitySpecification(xmlQualitySpecification);

            var modelFactory =
                new VerifiedModelFactory(CreateWorkspaceContext,
                                         new SimpleVerifiedDatasetHarvester());

            var factory = new XmlBasedQualitySpecificationFactory(
                modelFactory, new SimpleDatasetOpener(new MasterDatabaseDatasetContext()));

            QualitySpecification qualitySpecification =
                factory.CreateQualitySpecification(xmlDocument, xmlQualitySpecification.Name,
                                                   new DataSource[] { });

            Assert.AreEqual(xmlQualitySpecification.Name, qualitySpecification.Name);
        }
示例#2
0
        private void CanCreateQualitySpecificationCore()
        {
            var    locator     = TestDataLocator.Create("ProSuite", @"QA\TestData");
            string catalogPath = locator.GetPath("QATestData.mdb");

            var xmlCategory = new XmlDataQualityCategory {
                Name = "Category A"
            };
            var xmlSubCategory = new XmlDataQualityCategory {
                Name = "Category A.1"
            };
            var xmlSubSubCategory = new XmlDataQualityCategory {
                Name = "Category A.1.1"
            };
            var xmlSubSubCategory2 = new XmlDataQualityCategory {
                Name = "Category A.1.2"
            };

            xmlCategory.AddSubCategory(xmlSubCategory);
            xmlSubCategory.AddSubCategory(xmlSubSubCategory);
            xmlSubCategory.AddSubCategory(xmlSubSubCategory2);

            var xmlQCon = new XmlQualityCondition
            {
                Name = "MinArea",
                TestDescriptorName = _xmlTestDescriptorMinArea.Name
            };

            xmlQCon.ParameterValues.Add(new XmlDatasetTestParameterValue
            {
                TestParameterName = "polygonClass",
                Value             = "polygons",
                WorkspaceId       = _xmlWorkspace.ID
            });
            xmlQCon.ParameterValues.Add(new XmlScalarTestParameterValue
            {
                TestParameterName = "limit",
                Value             = "12.34"
            });

            var xmlQSpec = new XmlQualitySpecification {
                Name = "qspec"
            };

            xmlQSpec.Elements.Add(new XmlQualitySpecificationElement
            {
                QualityConditionName = xmlQCon.Name
            });

            var xmlDocument = new XmlDataQualityDocument();

            xmlDocument.AddCategory(xmlCategory);
            xmlDocument.AddWorkspace(_xmlWorkspace);
            //xmlDocument.AddQualitySpecification(xmlQSpec);
            //xmlDocument.AddQualityCondition(xmlQCon);
            xmlDocument.AddTestDescriptor(_xmlTestDescriptorMinArea);

            xmlSubCategory.AddQualitySpecification(xmlQSpec);
            xmlSubSubCategory.AddQualityCondition(xmlQCon);

            var modelFactory =
                new VerifiedModelFactory(CreateWorkspaceContext,
                                         new SimpleVerifiedDatasetHarvester());

            var factory = new XmlBasedQualitySpecificationFactory(
                modelFactory, new SimpleDatasetOpener(new MasterDatabaseDatasetContext()));

            var dataSource = new DataSource(_xmlWorkspace)
            {
                WorkspaceAsText = catalogPath
            };

            QualitySpecification qualitySpecification =
                factory.CreateQualitySpecification(xmlDocument, xmlQSpec.Name,
                                                   new[] { dataSource });

            Assert.NotNull(qualitySpecification.Category);
            Assert.AreEqual(xmlQSpec.Name, qualitySpecification.Name);
            Assert.AreEqual(1, qualitySpecification.Elements.Count);
            if (qualitySpecification.Category != null)
            {
                Assert.AreEqual(xmlSubCategory.Name, qualitySpecification.Category.Name);
                Assert.NotNull(qualitySpecification.Category.ParentCategory);
                if (qualitySpecification.Category.ParentCategory != null)
                {
                    Assert.AreEqual(xmlCategory.Name,
                                    qualitySpecification.Category.ParentCategory.Name);
                }

                Assert.AreEqual(2, qualitySpecification.Category.SubCategories.Count);
            }

            QualityCondition qualityCondition =
                qualitySpecification.Elements[0].QualityCondition;

            Assert.AreEqual(xmlQCon.Name, qualityCondition.Name);
            Assert.NotNull(qualityCondition.Category);
            if (qualityCondition.Category != null)
            {
                Assert.AreEqual(xmlSubSubCategory.Name, qualityCondition.Category.Name);
                Assert.NotNull(qualityCondition.Category.ParentCategory);
                if (qualityCondition.Category.ParentCategory != null)
                {
                    Assert.AreEqual(xmlSubCategory.Name,
                                    qualityCondition.Category.ParentCategory.Name);
                }
            }

            var value =
                (ScalarTestParameterValue)qualityCondition.GetParameterValues("limit")[0];

            Assert.AreEqual(12.34, value.GetValue(typeof(double)));
        }
示例#3
0
        public void CanCreateQualitySpecificationIgnoringUnkownDatasets()
        {
            var    locator     = TestDataLocator.Create("ProSuite", @"QA\TestData");
            string catalogPath = locator.GetPath("QATestData.mdb");

            var xmlQCon = new XmlQualityCondition
            {
                Name = "Simple",
                TestDescriptorName = _xmlTestDescriptorSimple.Name
            };

            xmlQCon.ParameterValues.Add(new XmlDatasetTestParameterValue
            {
                TestParameterName = "featureClass",
                Value             = "UNKNOWN",
                WorkspaceId       = _xmlWorkspace.ID
            });

            var xmlQSpec = new XmlQualitySpecification {
                Name = "qspec"
            };

            xmlQSpec.Elements.Add(new XmlQualitySpecificationElement
            {
                QualityConditionName = xmlQCon.Name
            });

            var xmlDocument = new XmlDataQualityDocument();

            xmlDocument.AddWorkspace(_xmlWorkspace);
            xmlDocument.AddQualitySpecification(xmlQSpec);
            xmlDocument.AddQualityCondition(xmlQCon);
            xmlDocument.AddTestDescriptor(_xmlTestDescriptorSimple);

            var modelFactory =
                new VerifiedModelFactory(CreateWorkspaceContext,
                                         new SimpleVerifiedDatasetHarvester());

            var factory = new XmlBasedQualitySpecificationFactory(
                modelFactory, new SimpleDatasetOpener(new MasterDatabaseDatasetContext()));

            var dataSource = new DataSource(_xmlWorkspace)
            {
                WorkspaceAsText = catalogPath
            };

            const bool ignoreConditionsForUnknownDatasets = true;

            QualitySpecification qualitySpecification;

            try
            {
                qualitySpecification =
                    factory.CreateQualitySpecification(xmlDocument, xmlQSpec.Name,
                                                       new[] { dataSource },
                                                       ignoreConditionsForUnknownDatasets);
            }
            catch (Exception)
            {
                // TODO: Move test data to different format
                if (EnvironmentUtils.Is64BitProcess)
                {
                    Console.WriteLine("Expected exception: PGDB is not supported on x64");
                    return;
                }

                throw;
            }

            Assert.AreEqual(xmlQSpec.Name, qualitySpecification.Name);
            Assert.AreEqual(0, qualitySpecification.Elements.Count);
        }