当前位置: 首页>>代码示例>>C#>>正文


C# TestMethod.ApplyAttributesToTest方法代码示例

本文整理汇总了C#中TestMethod.ApplyAttributesToTest方法的典型用法代码示例。如果您正苦于以下问题:C# TestMethod.ApplyAttributesToTest方法的具体用法?C# TestMethod.ApplyAttributesToTest怎么用?C# TestMethod.ApplyAttributesToTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestMethod的用法示例。


在下文中一共展示了TestMethod.ApplyAttributesToTest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildTestMethod

        /// <summary>
        /// Builds a single NUnitTestMethod, either as a child of the fixture
        /// or as one of a set of test cases under a ParameterizedTestMethodSuite.
        /// </summary>
        /// <param name="method">The MethodInfo from which to construct the TestMethod</param>
        /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
        /// <param name="parms">The ParameterSet to be used, or null</param>
        /// <returns></returns>
        public TestMethod BuildTestMethod(IMethodInfo method, Test parentSuite, TestCaseParameters parms)
        {
            var testMethod = new TestMethod(method, parentSuite)
            {
                Seed = _randomizer.Next()
            };

            CheckTestMethodSignature(testMethod, parms);

            if (parms == null || parms.Arguments == null)
                testMethod.ApplyAttributesToTest(method.MethodInfo);

            // NOTE: After the call to CheckTestMethodSignature, the Method
            // property of testMethod may no longer be the same as the
            // original MethodInfo, so we don't use it here.
            string prefix = testMethod.Method.TypeInfo.FullName;

            // Needed to give proper fullname to test in a parameterized fixture.
            // Without this, the arguments to the fixture are not included.
            if (parentSuite != null)
                prefix = parentSuite.FullName;

            if (parms != null)
            {
                parms.ApplyToTest(testMethod);

                if (parms.TestName != null)
                {
                    // The test is simply for efficiency
                    testMethod.Name = parms.TestName.Contains("{")
                        ? new TestNameGenerator(parms.TestName).GetDisplayName(testMethod, parms.OriginalArguments)
                        : parms.TestName;
                }
                else
                {
                    testMethod.Name = _nameGenerator.GetDisplayName(testMethod, parms.OriginalArguments);
                }
            }
            else
            {
                testMethod.Name = _nameGenerator.GetDisplayName(testMethod, null);
            }

            testMethod.FullName = prefix + "." + testMethod.Name;

            return testMethod;
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:55,代码来源:NUnitTestCaseBuilder.cs

示例2: BuildTestMethod

        /// <summary>
        /// Builds a single NUnitTestMethod, either as a child of the fixture
        /// or as one of a set of test cases under a ParameterizedTestMethodSuite.
        /// </summary>
        /// <param name="method">The MethodInfo from which to construct the TestMethod</param>
        /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
        /// <param name="parms">The ParameterSet to be used, or null</param>
        /// <returns></returns>
        public TestMethod BuildTestMethod(MethodInfo method, Test parentSuite, TestCaseParameters parms)
        {
            var testMethod = new TestMethod(method, parentSuite)
            {
                Seed = randomizer.Next()
            };

            string prefix = method.ReflectedType.FullName;

            // Needed to give proper fullname to test in a parameterized fixture.
            // Without this, the arguments to the fixture are not included.
            if (parentSuite != null)
                prefix = parentSuite.FullName;

            if (CheckTestMethodSignature(testMethod, parms))
            {
                if (parms == null || parms.Arguments == null)
                    testMethod.ApplyAttributesToTest(method);
            }

            if (parms != null)
            {
                // NOTE: After the call to CheckTestMethodSignature, the Method
                // property of testMethod may no longer be the same as the
                // original MethodInfo, so we reassign it here.
                method = testMethod.Method;

                if (parms.TestName != null)
                {
                    testMethod.Name = parms.TestName;
                    testMethod.FullName = prefix + "." + parms.TestName;
                }
                else if (parms.OriginalArguments != null)
                {
                    string name = MethodHelper.GetDisplayName(method, parms.OriginalArguments);
                    testMethod.Name = name;
                    testMethod.FullName = prefix + "." + name;
                }

                parms.ApplyToTest(testMethod);
            }

            return testMethod;
        }
开发者ID:ewassef,项目名称:nunit,代码行数:52,代码来源:NUnitTestCaseBuilder.cs


注:本文中的TestMethod.ApplyAttributesToTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。