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);
            }
        }
        private XmlElement GetSignatureRow([NotNull] TestFactory testFactory)
        {
            string signature = TestImplementationUtils.GetTestSignature(testFactory);

            XmlElement signatureRow = CreateTableRow();

            signatureRow.AppendChild(CreateTableCell("Signature:"));
            signatureRow.AppendChild(CreateTableCell(signature, 2, "code"));
            return(signatureRow);
        }
Exemple #3
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);
            }
        }