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; }
/// <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; }
public void SetValue <T>(Dimension <T> dimension, T value) { SetBaseValue(dimension, value); }
public Category <T> GetCategory <T>(Dimension <T> dimension) { return((Category <T>)GetBaseCategory(dimension)); }
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)); }
public static RandomIntegerRangeStrategy RandomRange(this Dimension <int> dimension, int inclusiveLowerLimit, int exclusiveUpperLimit, Func <int, int, int> nextIntInRange) { return(new RandomIntegerRangeStrategy(inclusiveLowerLimit, exclusiveUpperLimit, nextIntInRange)); }
/// <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)); }
public T GetValue <T>(Dimension <T> dimension) { return((T)GetBaseValue(dimension)); }
/// <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))); }
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)); }
public static ExhaustiveIEnumerableStrategy <T> Values <T>(this Dimension <T> dimension, IEnumerable <T> wantedValues) { return(new ExhaustiveIEnumerableStrategy <T>(wantedValues)); }
public static CategoricalStrategy <T> Categorized <T>(this Dimension <T> dimension, IEnumerable <Category <T> > categories) { return(new CategoricalStrategy <T>(categories)); }
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)); } } }
public void SetValue <T>(Dimension <T> dimension, T value, Category <T> category) { SetBaseValue(dimension, value, category); }
/// <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); }
public static IntegerRangeStrategy Range(this Dimension <int> dimension, int inclusiveLowerLimit, int exclusiveUpperLimit) { return(new IntegerRangeStrategy(inclusiveLowerLimit, exclusiveUpperLimit)); }
/// <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]); }
public static RandomEnumStrategy <T> RandomEnum <T>(this Dimension <T> dimension, Func <int, int> nextInt) { return(new RandomEnumStrategy <T>(nextInt)); }
public static RandomIEnumerableStrategy <T> Random <T>(this Dimension <T> dimension, Func <int, int> nextInt, IEnumerable <T> possibleValues) { return(new RandomIEnumerableStrategy <T>(nextInt, possibleValues)); }
/// <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)); }