예제 #1
0
        /// <summary>
        /// Method to add test cases to the newly constructed fixture.
        /// </summary>
        private void AddTestCasesToFixture(TestFixture fixture, IPreFilter filter)
        {
            // TODO: Check this logic added from Neil's build.
            if (fixture.TypeInfo.ContainsGenericParameters)
            {
                fixture.MakeInvalid(NO_TYPE_ARGS_MSG);
                return;
            }

            var methods = fixture.TypeInfo.GetMethods(
                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

            foreach (IMethodInfo method in methods)
            {
                if (filter.IsMatch(fixture.TypeInfo.Type, method.MethodInfo))
                {
                    Test test = BuildTestCase(method, fixture);

                    if (test != null)
                    {
                        fixture.Add(test);
                    }
                    else // it's not a test, check for disallowed attributes
                    if (method.MethodInfo.HasAttribute <ParallelizableAttribute>(false))
                    {
                        fixture.MakeInvalid(PARALLEL_NOT_ALLOWED_MSG);
                    }
                }
            }
        }
예제 #2
0
        private IList <Type> GetCandidateFixtureTypes(Assembly assembly)
        {
            var result = new List <Type>();

            foreach (Type type in assembly.GetTypes())
            {
                if (_filter.IsMatch(type))
                {
                    result.Add(type);
                }
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Method to add test cases to the newly constructed fixture.
        /// </summary>
        private void AddTestCasesToFixture(TestFixture fixture, IPreFilter filter)
        {
            // TODO: Check this logic added from Neil's build.
            if (fixture.TypeInfo.ContainsGenericParameters)
            {
                fixture.MakeInvalid(NO_TYPE_ARGS_MSG);
                return;
            }

            // We sort the methods in a deterministic order, since BuildTestCase() will invoke the
            // Randomizer to create seeds for each test. We want those seeds to be deterministically repeatable
            // so we can re-run the same conditions by manually fixing the Randomizer.InitialSeed.
            var methods = new SortedSet <IMethodInfo>(fixture.TypeInfo.GetMethods(
                                                          BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static),
                                                      MethodInfoComparer.Default);

            foreach (IMethodInfo method in methods)
            {
                // Generate the seed whether or not we use a filter to ensure we invoke the Randomizer to
                // move to the next random test seed (a test should always get the same seed in the sequence).
                Test test = BuildTestCase(method, fixture);

                _randomSeedInitializer.GenerateRandomSeeds(test);

                if (filter.IsMatch(fixture.TypeInfo.Type, method.MethodInfo))
                {
                    if (test != null)
                    {
                        fixture.Add(test);
                    }
                    else // it's not a test, check for disallowed attributes
                    if (method.MethodInfo.HasAttribute <ParallelizableAttribute>(false))
                    {
                        fixture.MakeInvalid(PARALLEL_NOT_ALLOWED_MSG);
                    }
                }
            }
        }