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;
 }
示例#2
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);
            }
        }