Пример #1
0
 /// <summary>
 /// </summary>
 public WPFXamlDefinition(int maxTotalElements,
                          int maxAttributes,
                          int maxChildren,
                          int maxDepth)
 {
     Initialize(DefaultRandomGenerator.GetGlobalRandomGenerator(), maxTotalElements, maxAttributes, maxChildren, maxDepth);
 }
Пример #2
0
        /// <summary>
        /// </summary>
        internal Type GetRandomObject(Type baseType)
        {
            if (!IsLibraryCreated)
            {
                return(null);
            }
            int index;

            if (baseType != typeof(object))
            {
                List <Type> types = new List <Type>(_types.Length);

                foreach (Type type in _types)
                {
                    if (baseType.IsAssignableFrom(type))
                    {
                        types.Add(type);
                    }
                }

                if (types.Count == 0)
                {
                    return(null);
                }

                index = DefaultRandomGenerator.GetGlobalRandomGenerator().Next(types.Count);

                return(types[index]);
            }

            index = DefaultRandomGenerator.GetGlobalRandomGenerator().Next(_types.Length);
            return(_types[index]);
        }
Пример #3
0
        /// <summary>
        /// </summary>
        internal string GetRandomBamlFile()
        {
            if (!IsLibraryCreated)
            {
                return(null);
            }

            if (_bamlFiles == null)
            {
                lock (_instanceLock)
                {
                    if (_bamlFiles == null)
                    {
                        _bamlFiles = Directory.GetFiles(_buildPath, "*.baml", SearchOption.AllDirectories);
                    }
                }
            }

            string bamlFile = _bamlFiles[DefaultRandomGenerator.GetGlobalRandomGenerator().Next(_bamlFiles.Length)];

            return(bamlFile);
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="max"></param>
 /// <returns></returns>
 static int GetRandomNumber(int max)
 {
     return(DefaultRandomGenerator.GetGlobalRandomGenerator().Next(max));
 }
Пример #5
0
 /// <summary>
 /// </summary>
 public WPFXamlDefinition() : this(DefaultRandomGenerator.GetGlobalRandomGenerator())
 {
 }
Пример #6
0
 /// <summary>
 /// Returns whether or not an action should throttle its behavior.
 /// </summary>
 /// <param name="numerator">
 /// Controls the probability of throttling as a fraction of the denominator.
 /// </param>
 /// <param name="denominator">
 /// Controls the probability of throttling.
 /// </param>
 /// <remarks>
 /// Actions often need to tune their behavior in order to prevent
 /// breaking the constraints of the overall stress app.  For example,
 /// an action that grows the size of a tree might need to prune the tree
 /// periodically in order to avoid using excessive memory for a long time.
 ///
 /// ShouldThrottle provides a simple mechanism for actions to make choices
 /// based on simple probabilites.  For example, the action that grows a tree
 /// could choose to prune the tree on average 1 out of every 3 times it runs.
 /// To do that, it can call ShouldThrottle(1, 3) and prune if it returns true.
 /// </remarks>
 /// <returns>True if the caller should modify its behavior to reduce resources.</returns>
 public static bool ShouldThrottle(int numerator, int denominator)
 {
     return(numerator > DefaultRandomGenerator.GetGlobalRandomGenerator().Next(denominator));
 }