Ejemplo n.º 1
0
        private void AddTestCasesToFixture(TestSuite fixture)
        {
            var methods = fixture.TypeInfo.GetMethods(
                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

            var tests = methods
                        .Where(method => _testBuilder.CanBuildFrom(method, fixture))
                        .Select(method => _testBuilder.BuildFrom(method, fixture));

            foreach (var test in tests)
            {
                fixture.Add(test);
            }
        }
Ejemplo n.º 2
0
        public void CanAddTestCaseBuilder()
        {
            ITestCaseBuilder mockBuilder = Substitute.For <ITestCaseBuilder>();

            mockBuilder.CanBuildFrom(null).Returns(true);

            IExtensionPoint ep = host.GetExtensionPoint("TestCaseBuilders");

            ep.Install(mockBuilder);
            ITestCaseBuilder builders = (ITestCaseBuilder)ep;

            builders.BuildFrom(null);

            mockBuilder.Received().BuildFrom(null);
        }
 /// <summary>
 /// Method to create a test case from a MethodInfo and add
 /// it to the fixture being built. It first checks to see if
 /// any global TestCaseBuilder addin wants to build the
 /// test case. If not, it uses the internal builder
 /// collection maintained by this fixture builder.
 ///
 /// The default implementation has no test case builders.
 /// Derived classes should add builders to the collection
 /// in their constructor.
 /// </summary>
 /// <param name="method">The MethodInfo for which a test is to be created</param>
 /// <param name="suite">The test suite being built.</param>
 /// <returns>A newly constructed Test</returns>
 private Test BuildTestCase(MethodInfo method, TestSuite suite)
 {
     return(testBuilder.CanBuildFrom(method, suite)
         ? testBuilder.BuildFrom(method, suite)
         : null);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Method to create a test case from a MethodInfo and add
 /// it to the fixture being built. It first checks to see if
 /// any global TestCaseBuilder addin wants to build the
 /// test case. If not, it uses the internal builder
 /// collection maintained by this fixture builder.
 ///
 /// The default implementation has no test case builders.
 /// Derived classes should add builders to the collection
 /// in their constructor.
 /// </summary>
 /// <param name="method">The method for which a test is to be created</param>
 /// <param name="suite">The test suite being built.</param>
 /// <returns>A newly constructed Test</returns>
 private Test BuildTestCase(FixtureMethod method, TestSuite suite)
 {
     return(_testBuilder.CanBuildFrom(method, suite)
         ? _testBuilder.BuildFrom(method, suite)
         : null);
 }