• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ITestMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITestMethod的典型用法代码示例。如果您正苦于以下问题:C# ITestMethod类的具体用法?C# ITestMethod怎么用?C# ITestMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITestMethod类属于命名空间,在下文中一共展示了ITestMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Discover

		public IEnumerable<IXunitTestCase> Discover (ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
		{
			var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault ();
			if (testMethod.Method.GetParameters ().Any ()) {
				return new IXunitTestCase[] {
					new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod,  "[VsixFact] methods are not allowed to have parameters.")
				};
			} else {
				var vsVersions = VsVersions.GetFinalVersions(testMethod.GetComputedProperty<string[]>(factAttribute, SpecialNames.VsixAttribute.VisualStudioVersions));
				// Process VS-specific traits.
				var suffix = testMethod.GetComputedArgument<string>(factAttribute, SpecialNames.VsixAttribute.RootSuffix) ?? "Exp";
				var newInstance = testMethod.GetComputedArgument<bool?>(factAttribute, SpecialNames.VsixAttribute.NewIdeInstance);
				var timeout = testMethod.GetComputedArgument<int?>(factAttribute, SpecialNames.VsixAttribute.TimeoutSeconds).GetValueOrDefault(XunitExtensions.DefaultTimeout);

				var testCases = new List<IXunitTestCase>();

				// Add invalid VS versions.
				testCases.AddRange (vsVersions
					.Where (v => !VsVersions.InstalledVersions.Contains (v))
					.Select (v => new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod,
						string.Format ("Cannot execute test for specified {0}={1} because there is no VSSDK installed for that version.", SpecialNames.VsixAttribute.VisualStudioVersions, v))));

				testCases.AddRange (vsVersions
					.Where (v => VsVersions.InstalledVersions.Contains (v))
					.Select (v => new VsixTestCase (messageSink, defaultMethodDisplay, testMethod, v, suffix, newInstance, timeout)));

				return testCases;
			}
		}
开发者ID:victorgarciaaprea,项目名称:xunit.vsix,代码行数:29,代码来源:VsixFactDiscoverer.cs


示例2: AssignTestExecutionMethodInfo

 public static void AssignTestExecutionMethodInfo(this TestExecutionMethod testExecutionMethod, ITestMethod testMethod)
 {
     var methodInfo = testMethod.Method;
     testExecutionMethod.NamespaceName = methodInfo.ReflectedType.Namespace;
     testExecutionMethod.ClassName = methodInfo.ReflectedType.ClassNameIncludingParentsIfNested();
     testExecutionMethod.MethodName = testMethod.Name;
 }
开发者ID:andywhitfield,项目名称:StatLight,代码行数:7,代码来源:ReflectionInfoHelper.cs


示例3: Discover

 public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
 {
     var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
     return factAttribute.GetNamedArgument<string>("Skip") != null
         ? new[] { new XunitTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) }
         : new XunitTestCase[] { new ScenarioTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) };
 }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:7,代码来源:ScenarioTestCaseDiscoverer.cs


示例4: BenchmarkTestCaseBase

        protected BenchmarkTestCaseBase(
            string variation,
            IMessageSink diagnosticMessageSink,
            ITestMethod testMethod,
            object[] testMethodArguments)
            : base(diagnosticMessageSink, TestMethodDisplay.Method, testMethod, null)
        {
            // Override display name to avoid getting info about TestMethodArguments in the
            // name (this is covered by the concept of Variation for benchmarks)
            var name = TestMethod.Method.GetCustomAttributes(typeof(FactAttribute))
                .First()
                .GetNamedArgument<string>("DisplayName") ?? BaseDisplayName;

            TestMethodName = name;
            DisplayName = $"{name} [Variation: {variation}]";

            DiagnosticMessageSink = diagnosticMessageSink;
            Variation = variation;

            var methodArguments = new List<object> { MetricCollector };
            if (testMethodArguments != null)
            {
                methodArguments.AddRange(testMethodArguments);
            }

            TestMethodArguments = methodArguments.ToArray();
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:27,代码来源:BenchmarkTestCaseBase.cs


示例5: KuduXunitTheoryTestCase

 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
开发者ID:NorimaConsulting,项目名称:kudu,代码行数:7,代码来源:KuduXunitTheoryTestCase.cs


示例6:

 public IEnumerable<IXunitTestCase> Discover
   ( ITestFrameworkDiscoveryOptions discoveryOptions
   , ITestMethod testMethod
   , IAttributeInfo factAttribute
   )
 {
     var inv = InvariantTestCase.InvariantFromMethod(testMethod);
     return
         inv == null
         ? new[]
           { new InvariantTestCase
               ( MessageSink
               , TestMethodDisplay.Method
               , testMethod
               , null
               )
           }
         : inv.AsSeq().Select
             ( i =>
                   new InvariantTestCase
                     ( MessageSink
                     , TestMethodDisplay.Method
                     , testMethod
                     , i
                     )
             );
 }
开发者ID:sharper-library,项目名称:Sharper.C.Testing,代码行数:27,代码来源:InvariantDiscoverer.cs


示例7: UnitTestMethodContainer

 /// <summary>
 /// Initializes dispatcher-stack attaching method container work item.
 /// </summary>
 /// <param name="testHarness">Test harness.</param>
 /// <param name="instance">Test instance.</param>
 /// <param name="method">Method reflection object.</param>
 /// <param name="testMethod">Test method metadata.</param>
 /// <param name="granularity">Granularity of test.</param>
 public UnitTestMethodContainer(UnitTestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity)
     : base(instance, method, testMethod)
 {
     _granularity = granularity;
     _harness = testHarness as UnitTestHarness;
     _testMethod = testMethod;
 }
开发者ID:shijiaxing,项目名称:SilverlightToolkit,代码行数:15,代码来源:UnitTestMethodContainer.cs


示例8: BenchmarkTestCase

        public BenchmarkTestCase(
                int iterations,
                int warmupIterations,
                string variation,
                IMessageSink diagnosticMessageSink,
                ITestMethod testMethod,
                object[] testMethodArguments)
            : base(diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay.Method, testMethod, null)
        {
            // Override display name to avoid getting info about TestMethodArguments in the
            // name (this is covered by the concept of Variation for benchmarks)
            var suppliedDisplayName = TestMethod.Method.GetCustomAttributes(typeof(FactAttribute))
                .First()
                .GetNamedArgument<string>("DisplayName");

            _diagnosticMessageSink = diagnosticMessageSink;
            DisplayName = suppliedDisplayName ?? BaseDisplayName;
            Variation = variation;
            Iterations = iterations;
            WarmupIterations = warmupIterations;

            var methodArguments = new List<object> { MetricCollector };
            if (testMethodArguments != null)
            {
                methodArguments.AddRange(testMethodArguments);
            }

            TestMethodArguments = methodArguments.ToArray();
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:29,代码来源:BenchmarkTestCase.cs


示例9: Discover

        public override IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();

            string conditionMemberName = factAttribute.GetConstructorArguments().FirstOrDefault() as string;
            MethodInfo conditionMethodInfo;
            if (conditionMemberName == null ||
                (conditionMethodInfo = LookupConditionalMethod(testMethodInfo.DeclaringType, conditionMemberName)) == null)
            {
                return new[] {
                    new ExecutionErrorTestCase(
                        _diagnosticMessageSink,
                        discoveryOptions.MethodDisplayOrDefault(),
                        testMethod,
                        GetFailedLookupString(conditionMemberName))
                };
            }

            IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
            if ((bool)conditionMethodInfo.Invoke(null, null))
            {
                return testCases;
            }
            else
            {
                string skippedReason = "\"" + conditionMemberName + "\" returned false.";
                return testCases.Select(tc => new SkippedTestCase(tc, skippedReason));
            }
        }
开发者ID:jango2015,项目名称:buildtools,代码行数:30,代码来源:ConditionalFactDiscoverer.cs


示例10: FindTestsForMethod

        /// <summary>
        /// Finds the tests on a test method.
        /// </summary>
        /// <param name="testMethod">The test method.</param>
        /// <param name="includeSourceInformation">Set to <c>true</c> to indicate that source information should be included.</param>
        /// <param name="messageBus">The message bus to report discovery messages to.</param>
        /// <param name="discoveryOptions">The options used by the test framework during discovery.</param>
        /// <returns>Return <c>true</c> to continue test discovery, <c>false</c>, otherwise.</returns>
        protected virtual bool FindTestsForMethod(ITestMethod testMethod, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions)
        {
            var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).FirstOrDefault();
            if (factAttribute == null)
                return true;

            var testCaseDiscovererAttribute = factAttribute.GetCustomAttributes(typeof(XunitTestCaseDiscovererAttribute)).FirstOrDefault();
            if (testCaseDiscovererAttribute == null)
                return true;

            var args = testCaseDiscovererAttribute.GetConstructorArguments().Cast<string>().ToList();
            var discovererType = SerializationHelper.GetType(args[1], args[0]);
            if (discovererType == null)
                return true;

            var discoverer = GetDiscoverer(discovererType);
            if (discoverer == null)
                return true;

            foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute))
                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                    return false;

            return true;
        }
开发者ID:remcomulder,项目名称:xunit,代码行数:33,代码来源:XunitTestFrameworkDiscoverer.cs


示例11: ScenarioResult

 /// <summary>
 /// Creates a result record.
 /// </summary>
 /// <param name="method">Test method metadata object.</param>
 /// <param name="testClass">Test class metadata object.</param>
 /// <param name="result">Test result object.</param>
 /// <param name="exception">Exception instance, if any.</param>
 public ScenarioResult(ITestMethod method, ITestClass testClass, TestOutcome result, Exception exception)
 {
     TestClass = testClass;
     TestMethod = method;
     Exception = exception;
     Result = result;
 }
开发者ID:shijiaxing,项目名称:SilverlightToolkit,代码行数:14,代码来源:ScenarioResult.cs


示例12: TestMethodManager

 /// <summary>
 /// Constructor for a test method manager, which handles executing a single test method 
 /// for a unit test provider.
 /// </summary>
 /// <param name="testHarness">The unit test harness object.</param>
 /// <param name="testClass">The test class metadata object.</param>
 /// <param name="testMethod">The test method metadata object.</param>
 /// <param name="instance">The test class instance.</param>
 /// <param name="provider">The unit test provider.</param>
 public TestMethodManager(UnitTestHarness testHarness, ITestClass testClass, ITestMethod testMethod, object instance, IUnitTestProvider provider)
     : base(testHarness, provider)
 {
     _testClass = testClass;
     _testMethod = testMethod;
     _instance = instance;
 }
开发者ID:jschementi,项目名称:silverlightut,代码行数:16,代码来源:TestMethodManager.cs


示例13: Discover

        public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
        {
            var variations = testMethod.Method
                .GetCustomAttributes(typeof(BenchmarkVariationAttribute))
                .ToDictionary(
                    a => a.GetNamedArgument<string>(nameof(BenchmarkVariationAttribute.VariationName)),
                    a => a.GetNamedArgument<object[]>(nameof(BenchmarkVariationAttribute.Data)));

            if (!variations.Any())
            {
                variations.Add("Default", new object[0]);
            }

            var tests = new List<IXunitTestCase>();
            foreach (var variation in variations)
            {
                tests.Add(new BenchmarkTestCase(
                    factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.Iterations)),
                    factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.WarmupIterations)),
                    variation.Key,
                    _diagnosticMessageSink,
                    testMethod,
                    variation.Value));
            }

            return tests;
        }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:27,代码来源:BenchmarkTestDiscoverer.cs


示例14: MethodContainer

 /// <summary>
 /// Constructs a new method container.
 /// </summary>
 /// <param name="instance">An instance of the method's type.</param>
 /// <param name="method">The method reflection object.</param>
 /// <param name="testMethod">The test method.</param>
 public MethodContainer(object instance, MethodInfo method, ITestMethod testMethod)
   : base()
 {
   _methodTask = new MethodInvokeWorkItem(instance, method, testMethod);
   _methodInfo = method;
   _method = testMethod;
 }
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:13,代码来源:MethodContainer.cs


示例15: Discover

 public override IEnumerable<IXunitTestCase> Discover(
     ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
 {
     string[] conditionMemberNames = factAttribute.GetConstructorArguments().FirstOrDefault() as string[];
     IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
     return ConditionalTestDiscoverer.Discover(discoveryOptions, _diagnosticMessageSink, testMethod, testCases, conditionMemberNames);
 }
开发者ID:dsgouda,项目名称:buildtools,代码行数:7,代码来源:ConditionalFactDiscoverer.cs


示例16: RetryTestRunFilter

 /// <summary>
 /// Initializes a new test run filter using an existing settings file.
 /// </summary>
 /// <param name="test">The test class metadata.</param>
 /// <param name="method">The test method metadata.</param>
 public RetryTestRunFilter(ITestClass test, ITestMethod method) : base(null, null)
 {
     TestRunName = "Retry of " + test.Name + " " + method.Name;
     
     _test = test;
     _method = method;
 }
开发者ID:dfr0,项目名称:moon,代码行数:12,代码来源:RetryTestRunFilter.cs


示例17: Discover

        public IEnumerable<IXunitTestCase> Discover(
            ITestFrameworkDiscoveryOptions discoveryOptions,
            ITestMethod testMethod,
            IAttributeInfo factAttribute)
        {
            var skipReason = EvaluateSkipConditions(testMethod);

            var isTheory = false;
            IXunitTestCaseDiscoverer innerDiscoverer;
            if (testMethod.Method.GetCustomAttributes(typeof(TheoryAttribute)).Any())
            {
                isTheory = true;
                innerDiscoverer = new TheoryDiscoverer(_diagnosticMessageSink);
            }
            else
            {
                innerDiscoverer = new FactDiscoverer(_diagnosticMessageSink);
            }

            var testCases = innerDiscoverer
                .Discover(discoveryOptions, testMethod, factAttribute)
                .Select(testCase => new SkipReasonTestCase(isTheory, skipReason, testCase));

            return testCases;
        }
开发者ID:krwq,项目名称:Testing,代码行数:25,代码来源:ConditionalAttributeDiscoverer.cs


示例18: FindTestsForMethod

        /// <summary>
        /// Finds the tests on a test method.
        /// </summary>
        /// <param name="testMethod">The test method.</param>
        /// <param name="includeSourceInformation">Set to <c>true</c> to indicate that source information should be included.</param>
        /// <param name="messageBus">The message bus to report discovery messages to.</param>
        /// <param name="discoveryOptions">The options used by the test framework during discovery.</param>
        /// <returns>Return <c>true</c> to continue test discovery, <c>false</c>, otherwise.</returns>
        protected virtual bool FindTestsForMethod(ITestMethod testMethod, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions)
        {
            var factAttributes = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).CastOrToList();
            if (factAttributes.Count > 1)
            {
                var message = string.Format("Test method '{0}.{1}' has multiple [Fact]-derived attributes", testMethod.TestClass.Class.Name, testMethod.Method.Name);
                var testCase = new ExecutionErrorTestCase(DiagnosticMessageSink, TestMethodDisplay.ClassAndMethod, testMethod, message);
                return ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus);
            }

            var factAttribute = factAttributes.FirstOrDefault();
            if (factAttribute == null)
                return true;

            var testCaseDiscovererAttribute = factAttribute.GetCustomAttributes(typeof(XunitTestCaseDiscovererAttribute)).FirstOrDefault();
            if (testCaseDiscovererAttribute == null)
                return true;

            var args = testCaseDiscovererAttribute.GetConstructorArguments().Cast<string>().ToList();
            var discovererType = SerializationHelper.GetType(args[1], args[0]);
            if (discovererType == null)
                return true;

            var discoverer = GetDiscoverer(discovererType);
            if (discoverer == null)
                return true;

            foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute))
                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                    return false;

            return true;
        }
开发者ID:ricardoshimoda,项目名称:xunit,代码行数:41,代码来源:XunitTestFrameworkDiscoverer.cs


示例19: MethodInvokeWorkItem

 /// <summary>
 /// Creates a new method invoke work item for a MethodInfo instance.
 /// </summary>
 /// <param name="instance">The type instance.</param>
 /// <param name="method">The method on the type to invoke when the 
 /// work item is executed.</param>
 /// <param name="testMethod">The test method metadata.</param>
 public MethodInvokeWorkItem(object instance, MethodInfo method, ITestMethod testMethod)
     : base()
 {
     _instance = instance;
     _method = method;
     _testMethod = testMethod;
 }
开发者ID:garyjohnson,项目名称:wpnest,代码行数:14,代码来源:MethodInvokeWorkItem.cs


示例20: Contains

 public bool Contains(ITestMethod testMethod) {
    foreach (var criterion in _criteria) {
       if (criterion.Contains(testMethod)) {
          return true;
       }
    }
    return false;
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:8,代码来源:OrCriterion.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITestOutputHelper类代码示例发布时间:2022-05-24
下一篇:
C# ITestListener类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap