Exemple #1
0
        private void BindTo([NotNull] TestDescriptor testDescriptor)
        {
            _textBoxName.Text           = testDescriptor.Name;
            _textBoxImplementation.Text = GetImplementation(testDescriptor);

            var testImplementationInfo =
                TestImplementationUtils.GetTestImplementationInfo(testDescriptor);

            _textBoxTestDescription.Text = testImplementationInfo == null
                                                               ? string.Empty
                                                               : testImplementationInfo.GetTestDescription();

            _textBoxCategories.Text = testImplementationInfo == null
                                                          ? string.Empty
                                                          : StringUtils.ConcatenateSorted(
                testImplementationInfo.TestCategories,
                ", ");
            try
            {
                _textBoxSignature.Text = testImplementationInfo == null
                                                                 ? "Unable to create test signature"
                                                                 : TestImplementationUtils.GetTestSignature(
                    testImplementationInfo);
            }
            catch (Exception e)
            {
                _textBoxSignature.Text = string.Format("Unable to get test signature ({0})",
                                                       e.Message);
            }
        }
Exemple #2
0
        private static bool ExcludeDependenciesWithinMultiValuedParameter(
            [NotNull] QualityCondition qualityCondition,
            [NotNull] string testParameterName)
        {
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));
            Assert.ArgumentNotNullOrEmpty(testParameterName, nameof(testParameterName));

            TestDescriptor testDescriptor = qualityCondition.TestDescriptor;

            if (testDescriptor == null)
            {
                return(false);
            }

            ClassDescriptor testClass = testDescriptor.TestClass;

            if (testClass != null)
            {
                if (testClass.TypeName.EndsWith("Other", StringComparison.OrdinalIgnoreCase))
                {
                    // naming convention: for "...Other" tests there is no dependency *within" each list parameter
                    return(true);
                }

                // TODO handle specific tests

                return(false);
            }

            return(false);
        }
        private static string GetDescription([NotNull] QualityCondition condition)
        {
            string description;

            if (string.IsNullOrEmpty(condition.Description))
            {
                TestDescriptor testDescriptor = condition.TestDescriptor;

                ITestImplementationInfo testImplementationInfo =
                    testDescriptor == null
                                                ? null
                                                : TestDescriptorUtils.GetTestImplementationInfo(testDescriptor);

                description = testImplementationInfo == null
                                                      ? string.Empty
                                                      : testImplementationInfo.GetTestDescription();
            }
            else
            {
                description = condition.Description;
            }

            if (description == null)
            {
                return(string.Empty);
            }

            description = description.Replace("\r", string.Empty);
            description = description.Replace("\n", Environment.NewLine);

            return(description);
        }
            public VerifiedConditionItem(
                [NotNull] QualityConditionVerification qualityConditionVerification)
            {
                Assert.ArgumentNotNull(qualityConditionVerification,
                                       nameof(qualityConditionVerification));

                QualityConditionVerification = qualityConditionVerification;
                QualityCondition qualityCondition =
                    Assert.NotNull(qualityConditionVerification.DisplayableCondition);
                TestDescriptor testDescriptor = qualityCondition.TestDescriptor;

                Name               = qualityCondition.Name;
                Category           = qualityCondition.Category?.GetQualifiedName();
                TestDescriptorName = testDescriptor.Name;
                TestCategories     = GetTestCategories(testDescriptor);
                DatasetNames       = GetDatasetNames(qualityCondition);

                IssueCount = qualityConditionVerification.ErrorCount;

                IssueType = qualityConditionVerification.AllowErrors
                                                    ? IssueType.Warning
                                                    : IssueType.Error;

                StatusImage = IssueCount == 0
                                                      ? _statusImageNoIssues
                                                      : qualityConditionVerification.AllowErrors
                                                              ? _statusImageHasWarnings
                                                              : _statusImageHasErrors;
            }
Exemple #5
0
 public static Image GetImage([CanBeNull] TestDescriptor testDescriptor)
 {
     return(testDescriptor == null
                                ? null
                                : GetImage(testDescriptor.AllowErrors,
                                           testDescriptor.StopOnError));
 }
        public void SetQualityCondition([CanBeNull] QualityCondition qualityCondition)
        {
            _testDescriptor = null;
            var paramValues = new BindingList <ParameterValueListItem>();

            if (qualityCondition != null)
            {
                _testDescriptor = qualityCondition.TestDescriptor;
                var paramDictionary = new Dictionary <string, List <TestParameterValue> >();
                foreach (TestParameterValue paramValue in qualityCondition.ParameterValues)
                {
                    List <TestParameterValue> valueList;
                    if (!paramDictionary.TryGetValue(paramValue.TestParameterName, out valueList))
                    {
                        valueList = new List <TestParameterValue>();
                        paramDictionary.Add(paramValue.TestParameterName, valueList);
                    }

                    valueList.Add(paramValue);
                }

                foreach (List <TestParameterValue> valueList in paramDictionary.Values)
                {
                    foreach (TestParameterValue paramValue in valueList)
                    {
                        paramValues.Add(new ParameterValueListItem(paramValue));
                    }
                }
            }

            BindToParameterValues(paramValues);
            ShowDescription = true;
        }
        public void CanGroupQualityConditionsWithCompleteExclusion()
        {
            var catA   = new DataQualityCategory("A");
            var catA1  = new DataQualityCategory("A1");
            var catA11 = new DataQualityCategory("A11");

            catA.AddSubCategory(catA1);
            catA1.AddSubCategory(catA11);

            var test = new TestDescriptor("test", new ClassDescriptor(typeof(QaMinSegAngle)));

            var qc1 = new QualityCondition("qc1", test)
            {
                Category = catA11
            };
            var qc2 = new QualityCondition("qc2", test)
            {
                Category = catA11
            };
            var qc3 = new QualityCondition("qc3", test)
            {
                Category = catA11
            };

            var issueGroups = new List <IssueGroup>
            {
                CreateIssueGroup(qc1, "ic1", 3),
                CreateIssueGroup(qc2, "ic2", 4),
                CreateIssueGroup(qc3, "ic3", 5),
                CreateIssueGroup(qc3, "ic4", 6)
            };

            var reportDefinition = new HtmlReportDefinition(
                "templatepath", "fileName",
                new List <HtmlDataQualityCategoryOptions>
            {
                new HtmlDataQualityCategoryOptions(catA.Uuid, ignoreCategoryLevel: true),
                new HtmlDataQualityCategoryOptions(catA1.Uuid, ignoreCategoryLevel: true),
                new HtmlDataQualityCategoryOptions(catA11.Uuid, ignoreCategoryLevel: true),
            });

            List <HtmlReportIssueGroup>          reportIssueGroups;
            List <HtmlReportDataQualityCategory> reportCategories =
                GroupByCategories(issueGroups, reportDefinition,
                                  out reportIssueGroups);

            Assert.AreEqual(4, reportIssueGroups.Count);
            Assert.AreEqual(18, reportIssueGroups.Sum(ig => ig.IssueCount));

            Assert.AreEqual(1, reportCategories.Count);
            Assert.AreEqual(18, reportCategories.Sum(qc => qc.IssueCount));

            List <HtmlReportDataQualityCategory> rootCategories =
                reportCategories.Where(qc => qc.IsRoot)
                .ToList();

            Assert.AreEqual(1, rootCategories.Count);
            Assert.AreEqual(18, rootCategories.Sum(qc => qc.IssueCountWithChildren));
        }
        public void CanTestPseudoNodesFactory()
        {
            IFeatureWorkspace ws =
                TestWorkspaceUtils.CreateInMemoryWorkspace("CanTestPseudoNodes");
            IFeatureClass fc = CreateLineClass(ws);

            IFeature row1 = fc.CreateFeature();

            row1.Shape =
                CurveConstruction.StartLine(0, 0).LineTo(1, 1).LineTo(1, 0).LineTo(0, 0).Curve;
            row1.set_Value(fc.Fields.FindField(_nrFieldName), 1);
            row1.Store();

            var ds1 = (IDataset)fc;

            var     model = new SimpleModel("model", fc);
            Dataset mds1  = model.AddDataset(new ModelVectorDataset(ds1.Name));

            var clsDesc   = new ClassDescriptor(typeof(QaFactoryPseudoNodes));
            var tstDesc   = new TestDescriptor("GroupEnds", clsDesc);
            var condition = new QualityCondition("cndPseudoNodes", tstDesc);

            QualityConditionParameterUtils.AddParameterValue(
                condition, QaFactoryPseudoNodes.PolylineClassesParam, mds1);
            QualityConditionParameterUtils.AddParameterValue(
                condition, QaFactoryPseudoNodes.IgnoreFieldsParam, _nrFieldName);
            QualityConditionParameterUtils.AddParameterValue(
                condition, QaFactoryPseudoNodes.IgnoreFieldsParam,
                QaFactoryPseudoNodes.EndLayerFields);
            // implicit: ignoreLoopEndPoints = false

            var fact = new QaFactoryPseudoNodes();

            fact.Condition = condition;

            IList <ITest> tests =
                fact.CreateTests(new SimpleDatasetOpener(model.MasterDatabaseWorkspaceContext));

            Assert.AreEqual(1, tests.Count);

            ITest test   = tests[0];
            var   runner = new QaTestRunner(test);

            runner.Execute();
            Assert.AreEqual(1, runner.Errors.Count);

            // set ignoreLoopEndPoints = true and rerun
            QualityConditionParameterUtils.AddParameterValue(
                condition, QaFactoryPseudoNodes.IgnoreLoopEndPointsParam, true);
            fact.Condition = condition;

            tests = fact.CreateTests(new SimpleDatasetOpener(model.MasterDatabaseWorkspaceContext));
            Assert.AreEqual(1, tests.Count);

            test   = tests[0];
            runner = new QaTestRunner(test);
            runner.Execute();
            Assert.AreEqual(0, runner.Errors.Count);
        }
            private static string GetTestCategories([NotNull] TestDescriptor testDescriptor)
            {
                Type testType = GetTestType(testDescriptor);

                return(testType == null
                                               ? string.Empty
                                               : StringUtils.ConcatenateSorted(ReflectionUtils.GetCategories(testType),
                                                                               ", "));
            }
        public void CanGroupQualityConditionsWithoutExclusion()
        {
            var catA    = new DataQualityCategory("A");
            var catA1   = new DataQualityCategory("A1");
            var catA11  = new DataQualityCategory("A11");
            var catB    = new DataQualityCategory("B");
            var catB1   = new DataQualityCategory("B1");
            var catB11  = new DataQualityCategory("B11");
            var catB111 = new DataQualityCategory("B111");

            catA.AddSubCategory(catA1);
            catA1.AddSubCategory(catA11);
            catB.AddSubCategory(catB1);
            catB1.AddSubCategory(catB11);
            catB11.AddSubCategory(catB111);

            var test = new TestDescriptor("test", new ClassDescriptor(typeof(QaMinSegAngle)));

            var qc1 = new QualityCondition("qc1", test)
            {
                Category = catA11
            };
            var qc2 = new QualityCondition("qc2", test)
            {
                Category = catB11
            };
            var qc3 = new QualityCondition("qc3", test)
            {
                Category = catB11
            };

            var issueGroups = new List <IssueGroup>
            {
                CreateIssueGroup(qc1, "ic1", 3),
                CreateIssueGroup(qc2, "ic2", 4),
                CreateIssueGroup(qc3, "ic3", 5),
                CreateIssueGroup(qc3, "ic4", 6)
            };

            List <HtmlReportIssueGroup>          reportIssueGroups;
            List <HtmlReportDataQualityCategory> reportCategories =
                GroupByCategories(issueGroups, null, out reportIssueGroups);

            Assert.AreEqual(18, reportIssueGroups.Sum(ig => ig.IssueCount));

            Assert.AreEqual(6, reportCategories.Count);
            Assert.AreEqual(18, reportCategories.Sum(qc => qc.IssueCount));

            List <HtmlReportDataQualityCategory> rootCategories =
                reportCategories.Where(qc => qc.IsRoot)
                .ToList();

            Assert.AreEqual(2, rootCategories.Count);
            Assert.AreEqual(18, rootCategories.Sum(qc => qc.IssueCountWithChildren));
        }
        public void InitializePropertyNames_SimpleProperty_PropertyNameIsAssigned()
        {
            var descriptor = new TestDescriptor()
            {
                SimpleProperty = new VMPropertyDescriptor <string>()
            };

            descriptor.InitializePropertyNames();

            Assert.AreEqual("SimpleProperty", descriptor.SimpleProperty.PropertyName);
        }
 public bool Equals(TestDescriptor other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Target, Target) && Equals(other.Assembly, Assembly) && Equals(other.Type, Type));
 }
        public QualityCondition ToQualityCondition()
        {
            var clsDesc  = new ClassDescriptor(typeof(QaDatasetConstraintFactory));
            var testDesc = new TestDescriptor("QaDatasetConstraintFactory", clsDesc);
            var qc       = new QualityCondition("qc_dataset_" + Dataset.Name, testDesc);

            QualityConditionParameterUtils.AddParameterValue(
                qc, QaDatasetConstraintFactory.TableAttribute, Dataset);
            AddParameters(qc, Constraints, "");

            return(qc);
        }
        public void Properties_SimpleProperty_ReturnsCollection()
        {
            var descriptor = new TestDescriptor()
            {
                SimpleProperty = new VMPropertyDescriptor <string>()
            };

            CollectionAssert.AreEquivalent(
                new IVMPropertyDescriptor[] { descriptor.SimpleProperty },
                descriptor.Properties.ToArray()
                );
        }
Exemple #15
0
        public void Should_detect_optional_types(Type type, bool expected)
        {
            var property = new TestDescriptor("Test", type);

            if (expected)
            {
                property.IsOptional.ShouldBeTrue();
            }
            else
            {
                property.IsOptional.ShouldBeFalse();
            }
        }
        public void Build_InsertsProperViewModelBehaviors()
        {
            TestDescriptor d = VMDescriptorBuilder
                               .OfType <TestDescriptor>()
                               .For <TestVM>()
                               .WithProperties((_, __) => { })
                               .Build();

            Assert.IsNotNull(d);

            Assert.IsTrue(ContainsBehavior <LoadOrderBehavior>(d));
            Assert.IsTrue(ContainsBehavior <TypeDescriptorProviderBehavior>(d));
        }
Exemple #17
0
        private static string GetImplementation([NotNull] TestDescriptor testDescriptor)
        {
            if (testDescriptor.TestClass != null)
            {
                return(string.Format("{0} (constructor {1})",
                                     testDescriptor.TestClass.TypeName,
                                     testDescriptor.TestConstructorId));
            }

            return(testDescriptor.TestFactoryDescriptor != null
                                       ? testDescriptor.TestFactoryDescriptor.TypeName
                                       : string.Empty);
        }
Exemple #18
0
        public void DisabledTestShouldBeSkipped()
        {
            TestParser      parser = new TestParser();
            SystemUnderTest system = new SystemUnderTest(null, null, null);
            TestDescriptor  test   = new TestDescriptor()
            {
                Enabled = false,
            };

            var shouldRun = parser.ShouldRunTest(system, test);

            Assert.False(shouldRun);
        }
Exemple #19
0
        internal HtmlTestDescriptor([NotNull] TestDescriptor testDescriptor)
        {
            Assert.ArgumentNotNull(testDescriptor, nameof(testDescriptor));

            TestFactory testFactory =
                Assert.NotNull(TestDescriptorUtils.GetTestFactory(testDescriptor));

            Name        = testDescriptor.Name;
            Description = StringUtils.IsNotEmpty(testDescriptor.Description)
                                              ? testDescriptor.Description
                                              : null;

            TestDescription = testFactory.GetTestDescription();
            Signature       = TestImplementationUtils.GetTestSignature(testFactory);

            Type testType;

            if (testDescriptor.TestClass != null)
            {
                testType        = testDescriptor.TestClass.GetInstanceType();
                ConstructorId   = testDescriptor.TestConstructorId;
                UsesConstructor = true;
                IsObsolete      = TestDescriptorUtils.IsObsolete(testType, ConstructorId,
                                                                 out _obsoleteMessage);
            }
            else if (testDescriptor.TestFactoryDescriptor != null)
            {
                testType        = testDescriptor.TestFactoryDescriptor.GetInstanceType();
                ConstructorId   = -1;
                UsesConstructor = false;
                IsObsolete      = ReflectionUtils.IsObsolete(testType, out _obsoleteMessage);
            }
            else
            {
                throw new ArgumentException("Invalid test descriptor");
            }

            AssemblyName = Path.GetFileName(testType.Assembly.Location);
            ClassName    = testType.FullName;

            _issueCodes     = IssueCodeUtils.GetIssueCodes(testType).ToList();
            _testCategories = testFactory.TestCategories.OrderBy(c => c).ToList();

            foreach (TestParameter testParameter in testFactory.Parameters)
            {
                var htmlTestParameter = new HtmlTestParameter(testParameter);

                _parameters.Add(htmlTestParameter);
                _testParametersByName.Add(testParameter.Name, htmlTestParameter);
            }
        }
            private static Type GetTestType([NotNull] TestDescriptor testDescriptor)
            {
                Assert.ArgumentNotNull(testDescriptor, nameof(testDescriptor));

                if (testDescriptor.TestClass != null)
                {
                    return(PrivateAssemblyUtils.LoadType(testDescriptor.TestClass.AssemblyName,
                                                         testDescriptor.TestClass.TypeName));
                }

                if (testDescriptor.TestFactoryDescriptor != null)
                {
                    return(testDescriptor.TestFactoryDescriptor.GetInstanceType());
                }

                return(null);
            }
Exemple #21
0
        public void TestShouldNotRunOnBlacklistedPlatforms(string[] currentPlatforms, string[] platformBlacklist, bool expectedToRun)
        {
            TestParser      parser = new TestParser();
            SystemUnderTest system = new SystemUnderTest(
                runtimeVersion: Version.Parse("2.1"),
                sdkVersion: null,
                platformIds: currentPlatforms.ToList());
            TestDescriptor test = new TestDescriptor()
            {
                Enabled           = true,
                Version           = "2.1",
                PlatformBlacklist = platformBlacklist.ToList(),
            };

            var shouldRun = parser.ShouldRunTest(system, test);

            Assert.Equal(expectedToRun, shouldRun);
        }
Exemple #22
0
        public void VersionSpecificTestShouldBeRunForSameMajorMinorVersion(string version, bool expectedToRun)
        {
            TestParser      parser = new TestParser();
            SystemUnderTest system = new SystemUnderTest(
                runtimeVersion: Version.Parse(version),
                sdkVersion: null,
                platformIds: new List <string>());
            TestDescriptor test = new TestDescriptor()
            {
                Enabled         = true,
                VersionSpecific = true,
                Version         = "2.1",
            };

            var shouldRun = parser.ShouldRunTest(system, test);

            Assert.Equal(expectedToRun, shouldRun);
        }
Exemple #23
0
        public static TestFactory GetTestFactory([NotNull] TestDescriptor testDescriptor)
        {
            Assert.ArgumentNotNull(testDescriptor, nameof(testDescriptor));

            if (testDescriptor.TestClass != null)
            {
                return(new DefaultTestFactory(testDescriptor.TestClass.AssemblyName,
                                              testDescriptor.TestClass.TypeName,
                                              testDescriptor.TestConstructorId));
            }

            if (testDescriptor.TestFactoryDescriptor != null)
            {
                return(testDescriptor.TestFactoryDescriptor.CreateInstance <TestFactory>());
            }

            return(null);
        }
Exemple #24
0
        public IList <QualityCondition> Get(TestDescriptor testDescriptor)
        {
            Assert.ArgumentNotNull(testDescriptor, nameof(testDescriptor));

            if (!testDescriptor.IsPersistent)
            {
                return(new List <QualityCondition>());
            }

            using (ISession session = OpenSession(true))
            {
                return(session.CreateQuery(
                           "select qc " +
                           "  from QualityCondition qc " +
                           " where qc.TestDescriptor = :testDescriptor")
                       .SetEntity("testDescriptor", testDescriptor)
                       .List <QualityCondition>());
            }
        }
Exemple #25
0
        public void SdkTestsShouldRunOnlyWithSdk(string sdkVersion, bool requiresSdk, bool expectedToRun)
        {
            TestParser      parser = new TestParser();
            SystemUnderTest system = new SystemUnderTest(
                runtimeVersion: Version.Parse("3.1"),
                sdkVersion: Version.Parse(sdkVersion),
                platformIds: new List <string>());
            TestDescriptor test = new TestDescriptor()
            {
                Enabled         = true,
                RequiresSdk     = requiresSdk,
                VersionSpecific = false,
                Version         = "2.1",
            };

            var shouldRun = parser.ShouldRunTest(system, test);

            Assert.Equal(expectedToRun, shouldRun);
        }
        GetHtmlTestDescriptors([NotNull] QualitySpecification qualitySpecification)
        {
            Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification));

            var result = new Dictionary <TestDescriptor, HtmlTestDescriptor>();

            foreach (QualitySpecificationElement element in qualitySpecification.Elements)
            {
                TestDescriptor     testDescriptor = element.QualityCondition.TestDescriptor;
                HtmlTestDescriptor htmlTestDescriptor;
                if (!result.TryGetValue(testDescriptor, out htmlTestDescriptor))
                {
                    htmlTestDescriptor = new HtmlTestDescriptor(testDescriptor);
                    result.Add(testDescriptor, htmlTestDescriptor);
                }
            }

            return(result);
        }
Exemple #27
0
        private static XmlTestDescriptor GetTestDescriptor(
            [NotNull] TestDescriptor testDescriptor)
        {
            var result = new XmlTestDescriptor
            {
                Name        = Escape(testDescriptor.Name),
                Description = Escape(testDescriptor.Description),
                Assembly    = testDescriptor.TestAssemblyName
            };

            if (testDescriptor.TestClass != null)
            {
                result.TestClass            = testDescriptor.TestClass.TypeName;
                result.TestConstructorIndex =
                    testDescriptor.TestConstructorId.ToString(CultureInfo.InvariantCulture);
            }
            else if (testDescriptor.TestFactoryDescriptor != null)
            {
                result.FactoryClass = testDescriptor.TestFactoryDescriptor.TypeName;
            }

            return(result);
        }
Exemple #28
0
        public void CanGetAll()
        {
            TestDescriptor d1 = new TestDescriptor(
                "test1", new ClassDescriptor("factTypeName", "factAssemblyName"));

            TestDescriptor d2 = new TestDescriptor(
                "test2", new ClassDescriptor("factTypeName", "factAssemblyName__"),
                0, true, false, "desc");

            CreateSchema(d1, d2);

            UnitOfWork.NewTransaction(
                delegate
            {
                AssertUnitOfWorkHasNoChanges();
                IList <TestDescriptor> foundDescriptors = Repository.GetAll();

                Assert.AreEqual(2, foundDescriptors.Count);

                Assert.AreEqual(
                    "desc", foundDescriptors.Single(d => d.Name == "test2").Description);
            });
        }
Exemple #29
0
 public static int GetDefaultSortIndex([NotNull] TestDescriptor testDescriptor)
 {
     return(GetDefaultSortIndex(GetImageKey(testDescriptor)));
 }
Exemple #30
0
 public static string GetImageKey([CanBeNull] TestDescriptor testDescriptor)
 {
     return(testDescriptor == null
                                ? null
                                : GetImageKey(GetImage(testDescriptor)));
 }
 public bool Equals(TestDescriptor other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Target, Target) && Equals(other.Assembly, Assembly) && Equals(other.Type, Type);
 }