Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void BindTo([NotNull] TestDescriptor testDescriptor)
        {
            _textBoxName.Text           = testDescriptor.Name;
            _textBoxImplementation.Text = GetImplementation(testDescriptor);

            var testImplementationInfo =
                TestDescriptorUtils.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);
            }
        }
Ejemplo n.º 3
0
 public IncludedTestFactory([NotNull] Type testFactoryType)
     : base(GetTitle(testFactoryType),
            GetTestFactory(testFactoryType),
            testFactoryType.Assembly,
            ReflectionUtils.IsObsolete(testFactoryType),
            TestDescriptorUtils.IsInternallyUsed(testFactoryType))
 {
     _testFactoryType = testFactoryType;
 }
Ejemplo n.º 4
0
 public IncludedTestConstructor([NotNull] Type testType, int constructorIndex)
     : base(GetTitle(testType, constructorIndex),
            TestDescriptorUtils.GetTestFactory(testType, constructorIndex),
            testType.Assembly,
            TestDescriptorUtils.IsObsolete(testType, constructorIndex),
            TestDescriptorUtils.IsInternallyUsed(testType, constructorIndex))
 {
     _testType         = testType;
     _constructorIndex = constructorIndex;
 }
Ejemplo n.º 5
0
        public IncludedTestClass([NotNull] Type testType)
            : base(GetTitle(testType),
                   testType.Assembly,
                   ReflectionUtils.IsObsolete(testType),
                   TestDescriptorUtils.IsInternallyUsed(testType),
                   ReflectionUtils.GetCategories(testType))
        {
            Assert.ArgumentNotNull(testType, nameof(testType));

            _testType = testType;
        }
        private string GetParameterDescription([CanBeNull] string parameterName)
        {
            if (parameterName == null || _testDescriptor == null)
            {
                return(null);
            }

            var testFactory = TestDescriptorUtils.GetTestImplementationInfo(_testDescriptor);

            return(testFactory?.Parameters
                   .FirstOrDefault(x => x.Name == parameterName)
                   ?.Description);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        private static void IncludeTestFactories([NotNull] IReportBuilder reportBuilder,
                                                 [NotNull] IEnumerable <Assembly> assemblies)
        {
            const bool includeObsolete       = true;
            const bool includeInternallyUsed = true;

            foreach (Assembly assembly in assemblies)
            {
                foreach (Type testFactoryType in
                         TestDescriptorUtils.GetTestFactoryClasses(
                             assembly, includeObsolete, includeInternallyUsed))
                {
                    reportBuilder.IncludeTestFactory(testFactoryType);
                }
            }
        }