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

C# IAttributeInfo类代码示例

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

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



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

示例1: KuduXunitTheoryTestCase

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


示例2: GetTestFrameworkType

 public Type GetTestFrameworkType(IAttributeInfo attribute)
 {
     if (BenchmarkConfiguration.RunningAsPerfTest)
         return typeof(BenchmarkTestFramework);
     else
         return typeof(XunitTestFramework);
 }
开发者ID:visia,项目名称:xunit-performance,代码行数:7,代码来源:BenchmarkTestFrameworkTypeDiscoverer.cs


示例3:

 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


示例4: 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


示例5: CulturedXunitTestCase

        public CulturedXunitTestCase(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, string culture)
            : base(testCollection, assembly, type, method, factAttribute)
        {
            this.culture = culture;

            Traits.Add("Culture", culture);
        }
开发者ID:kerryjiang,项目名称:xunit,代码行数:7,代码来源:CulturedXunitTestCase.cs


示例6: 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


示例7: UnresolvedCustomAttributeData

        public UnresolvedCustomAttributeData(IAttributeInfo adapter)
        {
            if (adapter == null)
                throw new ArgumentNullException("adapter");

            this.adapter = adapter;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:UnresolvedCustomAttributeData.cs


示例8: 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


示例9: Initialize

        void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
        {
            string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
            ITypeInfo[] resolvedTypes = null;

            if (arguments != null && method.IsGenericMethodDefinition)
            {
                resolvedTypes = ResolveGenericTypes(method, arguments);
                method = method.MakeGenericMethod(resolvedTypes);
            }

            Assembly = assembly;
            Class = type;
            Method = method;
            Arguments = arguments;
            DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
            SkipReason = factAttribute.GetNamedArgument<string>("Skip");
            Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            TestCollection = testCollection;

            foreach (IAttributeInfo traitAttribute in Method.GetCustomAttributes(typeof(TraitAttribute))
                                                            .Concat(Class.GetCustomAttributes(typeof(TraitAttribute))))
            {
                var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
                Traits.Add((string)ctorArgs[0], (string)ctorArgs[1]);
            }

            uniqueID = new Lazy<string>(GetUniqueID, true);
        }
开发者ID:valmaev,项目名称:xunit,代码行数:29,代码来源:XunitTestCase.cs


示例10: GetData

        /// <inheritdoc/>
        public virtual IEnumerable<object[]> GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
        {
            var reflectionDataAttribute = dataAttribute as IReflectionAttributeInfo;
            var reflectionTestMethod = testMethod as IReflectionMethodInfo;

            if (reflectionDataAttribute != null && reflectionTestMethod != null)
            {
                var attribute = (DataAttribute)reflectionDataAttribute.Attribute;
                try
                {
                    return attribute.GetData(reflectionTestMethod.MethodInfo);
                }
                catch (ArgumentException)
                {
                    // If we couldn't find the data on the base type, check if it is in current type.
                    // This allows base classes to specify data that exists on a sub type, but not on the base type.
                    var memberDataAttribute = attribute as MemberDataAttribute;
                    var reflectionTestMethodType = reflectionTestMethod.Type as IReflectionTypeInfo;
                    if (memberDataAttribute != null && memberDataAttribute.MemberType == null)
                    {
                        memberDataAttribute.MemberType = reflectionTestMethodType.Type;
                    }
                    return attribute.GetData(reflectionTestMethod.MethodInfo);
                }
            }

            return null;
        }
开发者ID:commonsensesoftware,项目名称:xunit,代码行数:29,代码来源:DataDiscoverer.cs


示例11: 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


示例12: GetTraits

 /// <summary>
 /// Gets the trait values from the Category attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values.</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     TargetFrameworkMonikers platform = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();
     if (platform.HasFlag(TargetFrameworkMonikers.Net45))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet45Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net451))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet451Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net452))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet452Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net46))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet46Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net461))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet461Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net462))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet462Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Net463))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNet463Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcore50aot))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test);
     if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
         yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test);
 }
开发者ID:roncain,项目名称:buildtools,代码行数:31,代码来源:SkipOnTargetFrameworkDiscoverer.cs


示例13: 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


示例14: 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


示例15: Initialize

        void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
        {
            string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
            ITypeInfo[] resolvedTypes = null;

            if (arguments != null && method.IsGenericMethodDefinition)
            {
                resolvedTypes = ResolveGenericTypes(method, arguments);
                method = method.MakeGenericMethod(resolvedTypes);
            }

            Assembly = assembly;
            Class = type;
            Method = method;
            Arguments = arguments;
            DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
            SkipReason = factAttribute.GetNamedArgument<string>("Skip");
            Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            TestCollection = testCollection;

            foreach (var traitAttribute in Method.GetCustomAttributes(typeof(ITraitAttribute))
                                                 .Concat(Class.GetCustomAttributes(typeof(ITraitAttribute))))
            {
                var discovererAttribute = traitAttribute.GetCustomAttributes(typeof(TraitDiscovererAttribute)).First();
                var discoverer = ExtensibilityPointFactory.GetTraitDiscoverer(discovererAttribute);
                if (discoverer != null)
                    foreach (var keyValuePair in discoverer.GetTraits(traitAttribute))
                        Traits.Add(keyValuePair.Key, keyValuePair.Value);
            }

            uniqueID = new Lazy<string>(GetUniqueID, true);
        }
开发者ID:vkomarovsky-sugarcrm,项目名称:xunit,代码行数:32,代码来源:XunitTestCase.cs


示例16: GetMetrics

 public IEnumerable<PerformanceMetricInfo> GetMetrics(IAttributeInfo metricAttribute)
 {
     if (_profileSource != -1)
     {
         var interval = (int)(metricAttribute.GetConstructorArguments().FirstOrDefault() ?? DefaultInterval);
         yield return new InstructionsRetiredMetric(interval, _profileSource);
     }
 }
开发者ID:davmason,项目名称:xunit-performance,代码行数:8,代码来源:InstructionsRetiredMetricDiscoverer.cs


示例17: CreateTestCase

        protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) {
            if (testMethod.Method.ReturnType.Name == "System.Void" &&
                testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) {
                return new ExecutionErrorTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, "Async void methods are not supported.");
            }

            return new LegacyUITestCase(UITestCase.SyncContextType.WPF, diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
        }
开发者ID:Xarlot,项目名称:Xunit.StaFact,代码行数:8,代码来源:LegacyStaFactDiscoverer.cs


示例18: GetTraits

 /// <summary>
 /// Gets the trait values from the trait attribute.
 /// </summary>
 /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
 /// <returns>The trait values</returns>
 public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
 {
     IEnumerator<object> enumerator = traitAttribute.GetConstructorArguments().GetEnumerator();
     while (enumerator.MoveNext())
     {
         yield return new KeyValuePair<string, string>(enumerator.Current.ToString(), "");
     }
 }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:13,代码来源:TestCategoryDiscoverer.cs


示例19: KuduXunitTheoryTestCase

 public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
     DisableRetry = testAttribute == null ? true : testAttribute.GetNamedArgument<bool>("DisableRetry");
 }
开发者ID:sr457,项目名称:kudu,代码行数:8,代码来源:KuduXunitTheoryTestCase.cs


示例20: SupportsDiscoveryEnumeration

 /// <summary>
 /// Always returns 'false', indicating that discovery of tests is
 /// not supported.
 /// </summary>
 /// <param name="dataAttribute">The attribute</param>
 /// <param name="testMethod">The method being discovered</param>
 /// <returns>false</returns>
 public override bool SupportsDiscoveryEnumeration(
     IAttributeInfo dataAttribute, IMethodInfo testMethod)
 {
     // The data return by AutoDataAttribute is (like AutoFixture itself) typically
     // not 'stable'. In other words, the data often changes (e.g. string guids), and
     // therefore pre-discovery of tests decorated with this attribute is not possible.
     return false;
 }
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:15,代码来源:NoPreDiscoveryDataDiscoverer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IAttributeSet类代码示例发布时间:2022-05-24
下一篇:
C# IAttributeDefinition类代码示例发布时间: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