Beispiel #1
0
        /// <summary>
        /// Provide a function that will be invoked when T is need
        /// </summary>
        /// <typeparam name="T">type to return</typeparam>
        /// <param name="returnFunc">return function</param>
        /// <returns>configuration object</returns>
        public ReturnConfiguration <T> Return <T>(Func <DataRequest, T> returnFunc)
        {
            if (returnFunc == null)
            {
                throw new ArgumentNullException(nameof(returnFunc));
            }
            var convention = new FilteredConvention <T>(returnFunc);

            _returnConventions.AddConvention(convention);

            return(new ReturnConfiguration <T>(convention, this));
        }
Beispiel #2
0
        /// <summary>
        /// Return a set of T as an IEnumerable&lt;T&gt;
        /// </summary>
        /// <typeparam name="T">T Type for IEnumerable</typeparam>
        /// <param name="set">set of T</param>
        /// <returns>configuration object</returns>
        public ReturnConfiguration <IEnumerable <T> > ReturnIEnumerable <T>(params T[] set)
        {
            if (set == null)
            {
                throw new ArgumentNullException(nameof(set));
            }

            var convention = new FilteredConvention <IEnumerable <T> >(request => set);

            _returnConventions.AddConvention(convention);

            return(new ReturnConfiguration <IEnumerable <T> >(convention, this));
        }
Beispiel #3
0
        /// <summary>
        /// Return the specified sequence
        /// </summary>
        /// <typeparam name="T">Type to return</typeparam>
        /// <param name="returnValues">return values</param>
        /// <returns>configuration object</returns>
        public ReturnConfiguration <T> Return <T>(params T[] returnValues)
        {
            if (returnValues == null || returnValues.Length == 0)
            {
                throw new ArgumentNullException(nameof(returnValues), "you must provide at least one value");
            }

            var i = 0;

            var convention = new FilteredConvention <T>(g => returnValues[i++ % returnValues.Length]);

            _returnConventions.AddConvention(convention);

            return(new ReturnConfiguration <T>(convention, this));
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="convention">filter convention</param>
 /// <param name="fixture"></param>
 public ReturnConfiguration(FilteredConvention <T> convention, Fixture fixture)
 {
     _convention = convention;
     _fixture    = fixture;
 }