/// <summary>
 /// Creates a new instance of the <see cref="MockedDependency{T}"/> type.
 /// </summary>
 /// <param name="arrangements">
 /// A collection of user made arrangements for intercepted method or property calls.
 /// </param>
 /// <param name="interceptor">
 /// An interceptor that is injected in mock and will execute the user's <paramref name="arrangements"/>.
 /// </param>
 /// <param name="instance">
 /// A dynamic proxy instance that has the exact same signature as the mocked dependency.
 /// </param>
 public MockedDependency(IArrangementCollection arrangements, IInterceptor interceptor, T instance)
 {
     Arrangements = arrangements ?? throw new ArgumentNullException(nameof(arrangements));
     Interceptor  = interceptor ?? throw new ArgumentNullException(nameof(interceptor));
     Instance     = instance ?? throw new ArgumentNullException(nameof(instance));
     Signature    = typeof(T);
 }
        /// <inheritdoc cref="IInterceptorFactory" />
        public IInterceptor CreateInterceptorFor(MockBehavior behavior, IArrangementCollection arrangements)
        {
            Ensures.NotNull(arrangements);

            if (behavior == MockBehavior.Loose)
            {
                return(new LooseMockInterceptor(arrangements));
            }

            if (behavior == MockBehavior.Strict)
            {
                return(new StrictMockInterceptor(arrangements));
            }

            if (behavior == MockBehavior.Partial)
            {
                return(new PartialMockInterceptor(arrangements));
            }

            throw new NotSupportedException();
        }
 /// <summary>
 /// Creates a new instance of the <see cref="MockBehavior{TMock}"/> type.
 /// </summary>
 /// <param name="arrangements">
 /// The collection of arrangements that have been made for mocks of type <typeparamref name="TMock"/>.
 /// </param>
 public MockBehavior(IArrangementCollection arrangements)
 {
     Arrangements = arrangements ?? throw new ArgumentNullException(nameof(arrangements));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the <see cref="LooseMockInterceptor"/> type.
 /// </summary>
 /// <param name="arrangements"> A collection of <see cref="IArrangement"/>s for the intercepted calls. </param>
 public LooseMockInterceptor(IArrangementCollection arrangements)
 {
     Arrangements = arrangements ?? throw new ArgumentNullException(nameof(arrangements));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="CallBehavior{TMock}"/> type.
 /// </summary>
 /// <param name="arrangements"> The collection of arrangements that have been made for the associated mock. </param>
 /// <param name="signature"> The mocked method or property setter call. </param>
 /// <param name="mockBehavior"> The parent <see cref="IMockBehavior{TMock}"/> that created this instance. </param>
 public CallBehavior(IArrangementCollection arrangements, MethodInfo signature, IMockBehavior <TMock> mockBehavior)
 {
     Arrangements = arrangements ?? throw new ArgumentNullException(nameof(arrangements));
     Signature    = signature ?? throw new ArgumentNullException(nameof(signature));
     MockBehavior = mockBehavior ?? throw new ArgumentNullException(nameof(mockBehavior));
 }