示例#1
0
        /// <summary>
        /// Freezes a mock instance as the result for any further calls to <see cref="AnonymousData.Any"/>
        /// for the specified type.
        /// </summary>
        /// <typeparam name="T">The type to freeze.</typeparam>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="config">The delegate invoked to configure the mock behavior.</param>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception>
        public static void FreezeMock <T>(this IRegisterAnonymousData anon, Action <Mock <T> > config)
            where T : class
        {
            var mock = new Mock <T>();

            config?.Invoke(mock);
            anon.Freeze(mock);
        }
示例#2
0
        /// <summary>
        /// Freezes the specified value as the result for any further calls to <see cref="Any"/>
        /// for the specified type.
        /// </summary>
        /// <typeparam name="T">The type to freeze.</typeparam>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="value">The instance to freeze.</param>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception>
        public static void Freeze <T>(this IRegisterAnonymousData anon, T value)
        {
            Argument.NotNull(anon, nameof(anon));

            anon.Freeze(typeof(T), value);
        }
示例#3
0
 /// <summary>
 /// Freezes a mock instance as the result for any further calls to <see cref="AnonymousData.Any"/>
 /// for the specified type.
 /// </summary>
 /// <typeparam name="T">The type to freeze.</typeparam>
 /// <param name="anon">The anonymous data provider to use.</param>
 /// <param name="instance">The mock instance to freeze.</param>
 /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception>
 public static void FreezeMock <T>(this IRegisterAnonymousData anon, Mock <T> instance)
     where T : class =>
 anon.Freeze(instance);