Exemple #1
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 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)
        {
#if NUNITLITE
            return(testBuilder.CanBuildFrom(method, suite)
                ? testBuilder.BuildFrom(method, suite)
                : null);
#else
            return(testBuilder.BuildFrom(method, suite));
#endif
        }
        public void CanAddTestCaseBuilder2()
        {
            ITestCaseBuilder2 mockBuilder = Substitute.For <ITestCaseBuilder2>();

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

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

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

            builders.BuildFrom(null, null);

            mockBuilder.Received().BuildFrom(null, null);
        }
Exemple #3
0
        public void CanAddTestCaseBuilder2()
        {
            DynamicMock mock = new DynamicMock(typeof(ITestCaseBuilder2));

            mock.ExpectAndReturn("CanBuildFrom", true, null);
            mock.Expect("BuildFrom");

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

            ep.Install(mock.MockInstance);
            ITestCaseBuilder2 builders = (ITestCaseBuilder2)ep;

            builders.BuildFrom(null, null);

            mock.Verify();
        }
        /// <summary>
        /// Build a Test from the method provided.
        /// </summary>
        /// <param name="method">The method to be used</param>
        /// <returns>A Test or null</returns>
        public Test BuildFrom(MethodInfo method, Test suite)
        {
            foreach (ITestCaseBuilder builder in Extensions)
            {
                if (builder is ITestCaseBuilder2)
                {
                    ITestCaseBuilder2 builder2 = (ITestCaseBuilder2)builder;
                    if (builder2.CanBuildFrom(method, suite))
                        return builder2.BuildFrom(method, suite);
                }
                else if (builder.CanBuildFrom(method))
                    return builder.BuildFrom(method);
            }

            return null;
        }
 private Test BuildTestCase(MethodInfo method, TestSuite suite)
 {
     return(testBuilder.CanBuildFrom(method, suite) ? testBuilder.BuildFrom(method, suite) : null);
 }