private IEnumerable<TestRow> Explore(TestConfigurationMatrix matrix, TestMatrixExplorationKind explorationKind, TestRunStrategy testRunStrategy) { List<KeyValuePair<Dimension, IExplorationStrategy>> testShellDimensionsWithStrategies = new List<KeyValuePair<Dimension, IExplorationStrategy>>(); List<IConstraint> testShellContraints = new List<IConstraint>(); Dictionary<string, TestDimension> testDimensionsToExpand = new Dictionary<string, TestDimension>(); foreach (var testDimension in matrix.Dimensions) { testDimensionsToExpand.Add(testDimension.Name, testDimension); } // Now override any dimensions for the run Strategy if (testRunStrategy != null) { foreach (var testDimension in testRunStrategy.OverrideDimensions) { testDimensionsToExpand[testDimension.Name] = testDimension; } } // Add test matrix combinations this.GetFlattenDimensionsWithConstraints(testDimensionsToExpand.Values, testShellDimensionsWithStrategies, testShellContraints); // Create test dimension for the platforms var platformDimension = new Dimension<string>("Platform"); var platformExplorationStrategy = new ExhaustiveIEnumerableStrategy<string>(matrix.TestAssemblies.Select(ta => ta.PlatformType.ToString())); testShellDimensionsWithStrategies.Add(new KeyValuePair<Dimension, IExplorationStrategy>(platformDimension, platformExplorationStrategy)); CombinatorialStrategy testConfigurationExplorationStrategy = null; Matrix testShellMatrix = new Matrix(matrix.Name, testShellDimensionsWithStrategies.Select(pair => pair.Key).ToArray()); if (explorationKind == TestMatrixExplorationKind.Exhaustive) { testConfigurationExplorationStrategy = new ExhaustiveCombinatorialStrategy(testShellMatrix, testShellContraints); } else { testConfigurationExplorationStrategy = new PairwiseStrategy(testShellMatrix, this.RandomNumberGenerator.Next, testShellContraints); } foreach (var ds in testShellDimensionsWithStrategies) { testConfigurationExplorationStrategy.SetDimensionStrategy(ds.Key, ds.Value); } List<TestRow> testRows = new List<TestRow>(); foreach (var vector in testConfigurationExplorationStrategy.Explore()) { Dictionary<string, string> rowValues = new Dictionary<string, string>(); foreach (var testShellDimensionWithStrategy in testShellDimensionsWithStrategies) { rowValues.Add(testShellDimensionWithStrategy.Key.Name, (string)vector.GetValue(testShellDimensionWithStrategy.Key)); } testRows.Add(new TestRow(rowValues)); } return testRows; }
private IEnumerable <TestRow> Explore(TestConfigurationMatrix matrix, TestMatrixExplorationKind explorationKind, TestRunStrategy testRunStrategy) { List <KeyValuePair <Dimension, IExplorationStrategy> > testShellDimensionsWithStrategies = new List <KeyValuePair <Dimension, IExplorationStrategy> >(); List <IConstraint> testShellContraints = new List <IConstraint>(); Dictionary <string, TestDimension> testDimensionsToExpand = new Dictionary <string, TestDimension>(); foreach (var testDimension in matrix.Dimensions) { testDimensionsToExpand.Add(testDimension.Name, testDimension); } // Now override any dimensions for the run Strategy if (testRunStrategy != null) { foreach (var testDimension in testRunStrategy.OverrideDimensions) { testDimensionsToExpand[testDimension.Name] = testDimension; } } // Add test matrix combinations this.GetFlattenDimensionsWithConstraints(testDimensionsToExpand.Values, testShellDimensionsWithStrategies, testShellContraints); // Create test dimension for the platforms var platformDimension = new Dimension <string>("Platform"); var platformExplorationStrategy = new ExhaustiveIEnumerableStrategy <string>(matrix.TestAssemblies.Select(ta => ta.PlatformType.ToString())); testShellDimensionsWithStrategies.Add(new KeyValuePair <Dimension, IExplorationStrategy>(platformDimension, platformExplorationStrategy)); CombinatorialStrategy testConfigurationExplorationStrategy = null; Matrix testShellMatrix = new Matrix(matrix.Name, testShellDimensionsWithStrategies.Select(pair => pair.Key).ToArray()); if (explorationKind == TestMatrixExplorationKind.Exhaustive) { testConfigurationExplorationStrategy = new ExhaustiveCombinatorialStrategy(testShellMatrix, testShellContraints); } else { testConfigurationExplorationStrategy = new PairwiseStrategy(testShellMatrix, this.RandomNumberGenerator.Next, testShellContraints); } foreach (var ds in testShellDimensionsWithStrategies) { testConfigurationExplorationStrategy.SetDimensionStrategy(ds.Key, ds.Value); } List <TestRow> testRows = new List <TestRow>(); foreach (var vector in testConfigurationExplorationStrategy.Explore()) { Dictionary <string, string> rowValues = new Dictionary <string, string>(); foreach (var testShellDimensionWithStrategy in testShellDimensionsWithStrategies) { rowValues.Add(testShellDimensionWithStrategy.Key.Name, (string)vector.GetValue(testShellDimensionWithStrategy.Key)); } testRows.Add(new TestRow(rowValues)); } return(testRows); }