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


C# ITestMethod类代码示例

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


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


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