Exemple #1
0
        public void Test(int[] dimensions, int bestSoFar, int targetCases)
        {
            int features = dimensions.Length;

            string[][] sources = new string[features][];

            for (int i = 0; i < features; i++)
            {
                string featureName = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Substring(i, 1);

                int n = dimensions[i];
                sources[i] = new string[n];
                for (int j = 0; j < n; j++)
                {
                    sources[i][j] = featureName + j.ToString();
                }
            }

            ICombiningStrategy strategy = new PairwiseStrategy();

            PairCounter pairs = new PairCounter();
            int         cases = 0;

            foreach (NUnit.Framework.Internal.TestCaseParameters parms in strategy.GetTestCases(sources))
            {
                for (int i = 1; i < features; i++)
                {
                    for (int j = 0; j < i; j++)
                    {
                        string a = parms.Arguments[i] as string;
                        string b = parms.Arguments[j] as string;
                        pairs[a + b] = null;
                    }
                }

                ++cases;
            }

            int expectedPairs = 0;

            for (int i = 1; i < features; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    expectedPairs += dimensions[i] * dimensions[j];
                }
            }

            Assert.That(pairs.Count, Is.EqualTo(expectedPairs), "Number of pairs is incorrect");
            Assert.That(cases, Is.AtMost(bestSoFar), "Regression: Number of test cases exceeded target previously reached");
#if DEBUG
            //Assert.That(cases, Is.AtMost(targetCases), "Number of test cases exceeded target");
#endif
        }