/// <summary>
        /// Creates a constrained string based on a ConstrainedStringRequest.
        /// </summary>
        /// <param name="request">The request that describes what to create.</param>
        /// <param name="context">A context that can be used to create other specimens.</param>
        /// <returns>
        /// The requested number if possible; otherwise a <see cref="NoSpecimen"/> instance.
        /// </returns>
        public object Create(object request, ISpecimenContext context)
        {
            if (request == null)
            {
                return(new NoSpecimen());
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var constrain = request as ConstrainedStringRequest;

            if (constrain == null)
            {
                return(new NoSpecimen(request));
            }

            return(ConstrainedStringGenerator.Create(constrain.MinimumLength, constrain.MaximumLength, context));
        }
Exemple #2
0
        /// <summary>
        /// Creates a constrained string based on a ConstrainedStringRequest.
        /// </summary>
        /// <param name="request">The request that describes what to create.</param>
        /// <param name="context">A context that can be used to create other specimens.</param>
        /// <returns>
        /// The requested number if possible; otherwise a <see cref="NoSpecimen"/> instance.
        /// </returns>
        public object Create(object request, ISpecimenContext context)
        {
            if (request == null)
            {
                return(new NoSpecimen());
            }

            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var constrain = request as ConstrainedStringRequest;

            if (constrain == null)
            {
#pragma warning disable 618
                return(new NoSpecimen(request));

#pragma warning restore 618
            }

            return(ConstrainedStringGenerator.Create(constrain.MinimumLength, constrain.MaximumLength, context));
        }