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;
        }
示例#2
0
		/// <summary>
		/// Constructs a dimension-value pair.
		/// </summary>
		/// <param name="dimension">The dimension.</param>
		/// <param name="value">The value.</param>
		protected internal DimensionValuePair(Dimension dimension, object value)
		{
			if (dimension == null)
			{
				throw new ArgumentNullException("dimension");
			}
			_dimension = dimension;
			_value = value;
		}
示例#3
0
 public void SetValue <T>(Dimension <T> dimension, T value)
 {
     SetBaseValue(dimension, value);
 }
示例#4
0
 public Category <T> GetCategory <T>(Dimension <T> dimension)
 {
     return((Category <T>)GetBaseCategory(dimension));
 }
示例#5
0
 public static AllCombinationsStrategy <TCollection, TValue> AllCombinations <TCollection, TValue>(
     this Dimension <TCollection> dimension, IEnumerable <TValue> possibleValues)
     where TCollection : ICollection <TValue>, new()
 {
     return(new AllCombinationsStrategy <TCollection, TValue>(possibleValues));
 }
示例#6
0
 public static RandomIntegerRangeStrategy RandomRange(this Dimension <int> dimension, int inclusiveLowerLimit, int exclusiveUpperLimit, Func <int, int, int> nextIntInRange)
 {
     return(new RandomIntegerRangeStrategy(inclusiveLowerLimit, exclusiveUpperLimit, nextIntInRange));
 }
示例#7
0
 /// <summary>
 /// Restricts the coverage of a given category in a given dimension to a limited number of times.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="targetDimension">The target dimension.</param>
 /// <param name="limitedCategory">The category to restrict the coverage of.</param>
 /// <param name="maxCount">The maximum number of times to include this category in a vector.</param>
 public void RestrictCategoryCoverage <T>(Dimension <T> targetDimension,
                                          Category <T> limitedCategory, int maxCount)
 {
     _limitingInformation.Add(DimensionLimitingInformation <T> .LimitCategory(targetDimension, limitedCategory, maxCount));
 }
示例#8
0
 public T GetValue <T>(Dimension <T> dimension)
 {
     return((T)GetBaseValue(dimension));
 }
示例#9
0
 /// <summary>
 /// Gets the string representation for the value of the given dimension.
 /// </summary>
 /// <param name="dimension">The dimension.</param>
 /// <returns></returns>
 public string GetValueString(Dimension dimension)
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0}", GetBaseValue(dimension)));
 }
示例#10
0
 public static AllCombinationsStrategy <TCollection, TValue> AllCombinations <TCollection, TValue>(
     this Dimension <TCollection> dimension, bool allowEmptySet, params TValue[] possibleValues)
     where TCollection : ICollection <TValue>, new()
 {
     return(new AllCombinationsStrategy <TCollection, TValue>(allowEmptySet, possibleValues));
 }
示例#11
0
 public static ExhaustiveIEnumerableStrategy <T> Values <T>(this Dimension <T> dimension, IEnumerable <T> wantedValues)
 {
     return(new ExhaustiveIEnumerableStrategy <T>(wantedValues));
 }
示例#12
0
 public static CategoricalStrategy <T> Categorized <T>(this Dimension <T> dimension, IEnumerable <Category <T> > categories)
 {
     return(new CategoricalStrategy <T>(categories));
 }
示例#13
0
 public static CategoricalStrategy <T> Categorized <T>(this Dimension <T> dimension, params Category <T>[] categories)
 {
     return(new CategoricalStrategy <T>(categories));
 }
 public ExcludeVectorContraint(Dimension mainDimension, Dimension dependentDimension, string mainDimensionRequiredValue, string unspecifiedValue)
 {
     this.mainDimensionRequiredValue = mainDimensionRequiredValue;
     this.unspecifiedValue = unspecifiedValue;
     this.mainDimension = mainDimension;
     this.dependentDimension = dependentDimension;
     this.requiredDimensions = new List<QualifiedDimension>();
     this.requiredDimensions.Add(this.mainDimension);
     this.requiredDimensions.Add(this.dependentDimension);
 }
        private void GetFlattenDimensionsWithConstraints(IEnumerable<TestDimension> testDimensions, List<KeyValuePair<Dimension, IExplorationStrategy>> flattenedDimensions, List<IConstraint> contraints)
        {
            foreach (TestDimension testDimension in testDimensions)
            {
                var mainDimension = new Dimension<string>(testDimension.Name);
                flattenedDimensions.Add(new KeyValuePair<Dimension, IExplorationStrategy>(mainDimension, new ExhaustiveIEnumerableStrategy<string>(testDimension.Values)));

                this.GetFlattenDimensionsWithConstraints(testDimension.RequiredTestDimensionIfValueEqual.Values, flattenedDimensions, contraints);

                foreach (var dependentValueDimensionPair in testDimension.RequiredTestDimensionIfValueEqual)
                {
                    var dependentDimension = flattenedDimensions.Where(r => r.Key.Name == dependentValueDimensionPair.Value.Name).Select(r2 => r2.Key).SingleOrDefault();
                    ExceptionUtilities.CheckObjectNotNull(dependentDimension, "Should have a dependent dimension");
                    contraints.Add(new ExcludeVectorContraint(mainDimension, dependentDimension, dependentValueDimensionPair.Key, dependentValueDimensionPair.Value.UnspecifiedValue));
                }
            }
        }
示例#16
0
 public void SetValue <T>(Dimension <T> dimension, T value, Category <T> category)
 {
     SetBaseValue(dimension, value, category);
 }
示例#17
0
 /// <summary>
 /// Clears the dimension value.
 /// </summary>
 /// <param name="dimension">The dimension.</param>
 /// <exception cref="ArgumentNullException"><paramref name="dimension"/> is null</exception>
 public void ClearDimensionValue(Dimension dimension)
 {
     _dimensionValues.Remove(dimension);
 }
示例#18
0
 public static IntegerRangeStrategy Range(this Dimension <int> dimension, int inclusiveLowerLimit, int exclusiveUpperLimit)
 {
     return(new IntegerRangeStrategy(inclusiveLowerLimit, exclusiveUpperLimit));
 }
示例#19
0
 /// <summary>
 /// Gets the base value factory.
 /// </summary>
 /// <param name="dimension">The dimension.</param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"><paramref name="dimension"/> is null</exception>
 /// <exception cref="KeyNotFoundException">No value was ever set for this dimension.</exception>
 internal ValueFactoryWithOptionalConcreteValue GetValueFactoryWithOptionalConcreteValue(Dimension dimension)
 {
     return(_dimensionValues[dimension]);
 }
示例#20
0
 public static RandomEnumStrategy <T> RandomEnum <T>(this Dimension <T> dimension, Func <int, int> nextInt)
 {
     return(new RandomEnumStrategy <T>(nextInt));
 }
示例#21
0
 public static RandomIEnumerableStrategy <T> Random <T>(this Dimension <T> dimension, Func <int, int> nextInt, IEnumerable <T> possibleValues)
 {
     return(new RandomIEnumerableStrategy <T>(nextInt, possibleValues));
 }
示例#22
0
 /// <summary>
 /// Restricts the coverage of a given value in a given dimension to a limited number of times.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="targetDimension">The target dimension.</param>
 /// <param name="limitedValue">The value to restrict the coverage of.</param>
 /// <param name="maxCount">The maximum number of times to include this value in a vector.</param>
 public void RestrictValueCoverage <T>(Dimension <T> targetDimension,
                                       T limitedValue, int maxCount)
 {
     _limitingInformation.Add(DimensionLimitingInformation <T> .LimitValue(targetDimension, limitedValue, maxCount));
 }