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


C# IMethodInfo类代码示例

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


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

示例1: MethodTokenExpression

		public MethodTokenExpression(IMethodInfo method)
		{
			this.method = method;
#if !MONO
			declaringType = method.DeclaringType;
#endif
		}
开发者ID:rajgit31,项目名称:MetroUnitTestsDemoApp,代码行数:7,代码来源:MethodTokenExpression.cs

示例2: EnumerateTestCommands

        protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
        {
            if (method == null)
            {
                return new[] { new ExceptionCommand(new MethodCall(method), new ArgumentNullException("method")) };
            }

            IEnumerable<ITestCommand> backgroundCommands;
            IEnumerable<ICommand> scenarioCommands;

            // NOTE: any exception must be wrapped in a command, otherwise the test runner will retry this method infinitely
            try
            {
                backgroundCommands = this.EnumerateBackgroundCommands(method).ToArray();
                scenarioCommands = this.EnumerateScenarioCommands(method).ToArray();
            }
            catch (Exception ex)
            {
                return new[] { new ExceptionCommand(new MethodCall(method), ex) };
            }

            // NOTE: this is not in the try catch since we are yielding internally
            // TODO: address this - see http://stackoverflow.com/a/346772/49241
            return scenarioCommands.SelectMany(
                scenarioCommand => CurrentScenario.ExtractCommands(scenarioCommand.MethodCall, backgroundCommands.Concat(new[] { scenarioCommand })));
        }
开发者ID:jamesfoster,项目名称:xbehave.net,代码行数:26,代码来源:ScenarioAttribute.cs

示例3: TestMethod

 /// <summary>
 /// Initializes a new instance of the <see cref="TestMethod"/> class.
 /// </summary>
 /// <param name="method">The method to be used as a test.</param>
 /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
 public TestMethod(IMethodInfo method, Test parentSuite) : base(method ) 
 {
     // Needed to give proper fullname to test in a parameterized fixture.
     // Without this, the arguments to the fixture are not included.
     if (parentSuite != null)
         FullName = parentSuite.FullName + "." + Name;
 }
开发者ID:rojac07,项目名称:nunit,代码行数:12,代码来源:TestMethod.cs

示例4: CreateTestCommands

 public IEnumerable<ITestCommand> CreateTestCommands(IMethodInfo testMethod, IFixtureSet fixtureSet)
 {
     foreach (var command in MethodUtility.GetTestCommands(testMethod))
     {
         yield return new ParadigmTestCommand(testMethod, fixtureSet.ApplyFixturesToCommand(command), GetNameFor(command), new ConstructorInvokingObjectFactory(_testClassType.Type, _parameters.Select(x => x.Value).ToArray()));
     }
 }
开发者ID:fulviogabana,项目名称:xUnit.Paradigms,代码行数:7,代码来源:ParadigmExemplar.cs

示例5: DecorateContainingScope

 /// <inheritdoc />
 protected override void DecorateContainingScope(IPatternScope containingScope, IMethodInfo methodInfo)
 {
     Type formattableType = methodInfo.Parameters[0].Resolve(true).ParameterType;
     var extensionPoints = (IExtensionPoints)RuntimeAccessor.ServiceLocator.ResolveByComponentId("Gallio.ExtensionPoints");
     CustomTestEnvironment.SetUpThreadChain.Before(() => extensionPoints.CustomFormatters.Register(formattableType, x => (string)methodInfo.Resolve(true).Invoke(this, new[] { x })));
     CustomTestEnvironment.TeardownThreadChain.After(() => extensionPoints.CustomFormatters.Unregister(formattableType));
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:8,代码来源:FormatterAttribute.cs

示例6: EnumerateTestCommands

 public IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo testMethod)
 {
     var commands = command.EnumerateTestCommands(testMethod).ToList();
     if (!commands.Any())
         commands.Add(new FactCommand(testMethod));
     return commands;
 }
开发者ID:Booksbaum,项目名称:resharper-xunit,代码行数:7,代码来源:HasRunWithKnownMethodTask.xunit1.cs

示例7: FailedResult

 public FailedResult(IMethodInfo method, Exception exception, string displayName)
     : base(method, displayName)
 {
     ExceptionType = exception.GetType().FullName;
     Message = ExceptionUtility.GetMessage(exception);
     StackTrace = ExceptionUtility.GetStackTrace(exception);
 }
开发者ID:paulecoyote,项目名称:xunit,代码行数:7,代码来源:FailedResult.cs

示例8: BuildFrom

        /// <summary>
        /// Construct one or more TestMethods from a given MethodInfo,
        /// using available parameter data.
        /// </summary>
        /// <param name="method">The MethodInfo for which tests are to be constructed.</param>
        /// <param name="suite">The suite to which the tests will be added.</param>
        /// <returns>One or more TestMethods</returns>
        public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            List<TestMethod> tests = new List<TestMethod>();
            
            IParameterInfo[] parameters = method.GetParameters();

            if (parameters.Length > 0)
            {
                IEnumerable[] sources = new IEnumerable[parameters.Length];

                try
                {
                    for (int i = 0; i < parameters.Length; i++)
                        sources[i] = _dataProvider.GetDataFor(parameters[i]);
                }
                catch (InvalidDataSourceException ex)
                {
                    var parms = new TestCaseParameters();
                    parms.RunState = RunState.NotRunnable;
                    parms.Properties.Set(PropertyNames.SkipReason, ex.Message);
                    tests.Add(_builder.BuildTestMethod(method, suite, parms));
                    return tests;
                }

                foreach (var parms in _strategy.GetTestCases(sources))
                    tests.Add(_builder.BuildTestMethod(method, suite, (TestCaseParameters)parms));
            }

            return tests;
        }
开发者ID:textmetal,项目名称:main,代码行数:37,代码来源:CombiningStrategyAttribute.cs

示例9: RepositoryTheoryCommand

 public RepositoryTheoryCommand(IMethodInfo method, RepositoryProvider provider)
     :base(method)
 {
     _provider = provider;
     DisplayName = string.Format(
             "{0} - DatabaseProvider: {1}", DisplayName, _provider);
 }
开发者ID:Wdovin,项目名称:vc-community,代码行数:7,代码来源:RepositoryTheoryCommand.cs

示例10: UnresolvedMethodInfo

        internal UnresolvedMethodInfo(IMethodInfo adapter)
        {
            if (adapter == null)
                throw new ArgumentNullException("adapter");

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

示例11: FindTestsForMethod

        /// <summary>
        /// Finds the tests on a test method.
        /// </summary>
        /// <param name="testCollection">The test collection that the test method belongs to.</param>
        /// <param name="type">The test class that the test method belongs to.</param>
        /// <param name="method">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>
        /// <returns>Return <c>true</c> to continue test discovery, <c>false</c>, otherwise.</returns>
        protected virtual bool FindTestsForMethod(ITestCollection testCollection, ITypeInfo type, IMethodInfo method, bool includeSourceInformation, IMessageBus messageBus)
        {
            var factAttribute = 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 = Reflector.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(testCollection, AssemblyInfo, type, method, factAttribute))
                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                    return false;

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

示例12: EnumerateTestCommands

    public IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo testMethod)
    {
        EnumerateTestCommands__Called = true;
        EnumerateTestCommands_TestMethod = testMethod;

        return EnumerateTestCommands__Result ?? testClassCommand.EnumerateTestCommands(testMethod);
    }
开发者ID:paulecoyote,项目名称:xunit,代码行数:7,代码来源:StubTestClassCommand.cs

示例13: MethodResult

 protected MethodResult(IMethodInfo method, string displayName)
     : this(method.Name,
            method.TypeName,
            displayName,
            MethodUtility.GetTraits(method))
 {
 }
开发者ID:nulltoken,项目名称:xunit,代码行数:7,代码来源:MethodResult.cs

示例14: EnumerateTestCommands

        protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
        {
            var commands = base.EnumerateTestCommands(method);
            var attrs = method.MethodInfo.GetCustomAttributes(typeof(DataAttribute), false);

            if (commands.Count() != attrs.Count())
            {
                throw new InvalidOperationException("Some data attribute doesn't generate test command");
            }

            var filteredCommands = new List<ITestCommand>();
            int index = 0;

            foreach (var command in commands)
            {
                var theoryCmd = command as TheoryCommand;
                var skippableData = attrs.ElementAt(index++) as ISkippable;
                if (skippableData != null &&
                    !string.IsNullOrEmpty(skippableData.SkipReason))
                {
                    SkipCommand cmd = new SkipCommand(method, theoryCmd.DisplayName, skippableData.SkipReason);
                    filteredCommands.Add(cmd);
                }
                else
                {
                    filteredCommands.Add(command);
                }
            }

            return filteredCommands;
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:31,代码来源:ExtendedTheoryAttribute.cs

示例15: EnumerateTestCommands

		protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
		{
			if (DateTime.Today < SkipUntil)
				return Enumerable.Empty<ITestCommand>();
			throw new InvalidOperationException("Time bombed fact expired");
			//return base.EnumerateTestCommands(method);
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:7,代码来源:TimeBombedFactAttribute.cs


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