Esempio n. 1
0
        protected override bool FindTestsForType(ITestClass testClass, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions)
        {
            foreach (var method in testClass.Class.GetMethods(false))
            {
                var benchmarkAttribute = method.GetCustomAttributes(typeof(BenchmarkAttribute)).SingleOrDefault();
                if (benchmarkAttribute == null)
                {
                    continue;
                }

                var iterations = benchmarkAttribute.GetNamedArgument <int>("Iterations");
                if (iterations <= 0)
                {
                    iterations = 50;
                }

                var collectGarbage = benchmarkAttribute.GetNamedArgument <bool>("CollectGarbage");

                var testCase = new BenchmarkTestCase(new TestMethod(testClass, method), iterations, collectGarbage);

                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
 public BenchmarkTest(BenchmarkTestCase testCase)
 {
     this.testCase = testCase;
 }