Esempio n. 1
0
 private void AssertTestItemIsNotSkippedWhenExplorationIsNotExhaustive(TestItem testItem, TestMatrixAttribute matrixAttribute)
 {
     // Note: because MatrixCombinationCallback is called on the test item after test matrix generation is complete
     // we cannot incorporate the callback as a constraint into the pairwise generation.
     // Hence we allow callback to return null (i.e. test item is skipped) only for the exhaustive exploration.
     ExceptionUtilities.Assert(
         testItem != null || matrixAttribute.ExplorationKind == TestMatrixExplorationKind.Exhaustive,
         "MatrixCombinationCallback retured null (i.e. skipping test item) - this is only allowed when doing exhaustive test matrix exploration.");
 }
Esempio n. 2
0
        private IEnumerable <TAttribute> GenerateTestAttributesFromMatrix <TAttribute>(TestMatrixAttribute matrix, IEnumerable <TestMatrixDimensionAttribute> dimensions, IEnumerable <KeyValuePair <MethodInfo, object> > constraintsInfo)
            where TAttribute : TestItemWithParametersAttribute, new()
        {
            var attributes      = new List <TAttribute>();
            int currentIdOffset = 0;
            TestMatrixExplorationKind explorationKind = this.ExplorationKind.HasValue ? this.ExplorationKind.Value : matrix.ExplorationKind;

            foreach (var row in this.GenerateMatrixFromDimensions(dimensions, constraintsInfo, explorationKind))
            {
                string suffix = " - " + string.Join(" ", row.Select(pair => pair.Key + "=" + pair.Value).ToArray());
                int    id     = matrix.Id;
                if (id > 0)
                {
                    id += currentIdOffset++;
                }

                string name = null;
                if (matrix.Name != null)
                {
                    name = matrix.Name + suffix;
                }

                string description = null;
                if (matrix.Description != null)
                {
                    description = matrix.Description + suffix;
                }

                attributes.Add(new TAttribute()
                {
                    Id          = id,
                    Name        = name,
                    Description = description,
                    Owner       = matrix.Owner,
                    Parameters  = row.Select(pair => pair.Value).ToArray(),
                    Priority    = matrix.Priority,
                    SkipReason  = matrix.SkipReason,
                    SkipUntil   = matrix.SkipUntil,
                    Timeout     = matrix.Timeout,
                    Version     = matrix.Version,
                });
            }

            return(attributes);
        }