static ParameterInteraction CreateInteraction(Model <T> model, Expression expression, IList <ParameterBase> parameters, ParameterExpression parameterExpr) { Func <T, bool> filter = expression is Expression <Func <T, bool> >? ((Expression <Func <T, bool> >)expression).Compile() : Expression.Lambda <Func <T, bool> >(expression, parameterExpr).Compile(); var parameterIndices = (from parameter in parameters select model.Parameters.IndexOf(parameter)).ToList(); parameterIndices.Sort(); ParameterInteraction interaction = new ParameterInteraction(parameterIndices); List <int[]> valueTable = ParameterInteractionTable <T> .GenerateValueTable(model.Parameters, interaction); foreach (var valueIndices in valueTable) { ValueCombinationState comboState = filter(BuildVariation(model, parameterIndices, valueIndices)) ? ValueCombinationState.Covered : ValueCombinationState.Excluded; interaction.Combinations.Add(new ValueCombination(valueIndices, interaction) { State = comboState }); } return(interaction); }
internal override ParameterInteraction GetExcludedCombinations(Model <T> model) { if (CachedInteraction == null) { var taggedValues = GetParametersWithTaggedValues(model); CachedInteraction = new ParameterInteraction(taggedValues.Select((p) => p.ParameterIndex)); var combinationIndices = ParameterInteractionTable <T> .GenerateValueTable(model.Parameters, CachedInteraction); foreach (var combinationIndex in combinationIndices) { int tagCount = 0; ValueCombination combination = new ValueCombination(combinationIndex, CachedInteraction); combination.State = ValueCombinationState.Covered; for (int i = 0; i < taggedValues.Count; i++) { if (taggedValues[i].ValueIndices.BinarySearch(combinationIndex[i]) >= 0) { tagCount++; } if (tagCount > 1) { break; } } if (tagCount > 1) { combination.State = ValueCombinationState.Excluded; } CachedInteraction.Combinations.Add(combination); } } return(new ParameterInteraction(CachedInteraction)); }