コード例 #1
0
        /// <summary>
        /// Generates an order-wise set of variations using the specified seed for random generation.
        /// </summary>
        /// <param name="order">The order of the selected combinations (2 is every pair, 3 is every triple, and so on). Must be between 1 and the number of parameters.</param>
        /// <param name="seed">The seed that is used for random generation.</param>
        /// <returns>The variations.</returns>
        public virtual IEnumerable <T> GenerateVariations(int order, int seed)
        {
            // create parameters and set values if model is supplied in a template
            propertiesMap = null;
            if (typeof(T) != typeof(Variation))
            {
                if (parameters.Count == 0)
                {
                    propertiesMap = CreateParameters(seed);
                }
                else
                {
                    propertiesMap = CreatePropertyMapFromParameters();
                }
            }


            // validate parameters
            if (order < 1 || order > Parameters.Count)
            {
                throw new ArgumentOutOfRangeException("order", order, "order must be between 1 and the number of parameters.");
            }

            if (typeof(T) == typeof(Variation))
            {
                return(VariationGenerator.GenerateVariations(this, order, seed).Cast <T>());
            }

            return(new VariationsWrapper <T>(propertiesMap,
                                             VariationGenerator.GenerateVariations(this, order, seed)));
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: yeungxh/TestApi
        /// <summary>
        /// Generate and order-wise set of variations using the specified seed for random generation.
        /// </summary>
        /// <param name="order">The order or the combinations selected (2 is every pair, 3 is every triple, etc). Must be between 1 and the number of parameters.</param>
        /// <param name="seed">The seed used for random generation.</param>
        /// <returns>The variations.</returns>
        public virtual IEnumerable <Variation> GenerateVariations(int order, int seed)
        {
            if (order < 1 || order > Parameters.Count)
            {
                throw new ArgumentOutOfRangeException("order", order, "order must be between 1 and the number of parameters.");
            }

            return(VariationGenerator.GenerateVariations(this, order, seed));
        }