diff --git a/src/Moq/ActionObserver.cs b/src/Moq/ActionObserver.cs index 3f5af5763..74d49b6ea 100644 --- a/src/Moq/ActionObserver.cs +++ b/src/Moq/ActionObserver.cs @@ -107,7 +107,7 @@ public override Expression> ReconstructExpression(Action action, } } - Expression[] GetArgumentExpressions(Invocation invocation, Match[] matches) + Expression[] GetArgumentExpressions(IInvocation invocation, Match[] matches) { // First, let's pretend that all arguments are constant values: var parameterTypes = invocation.Method.GetParameterTypes(); @@ -239,7 +239,7 @@ private sealed class Recorder : IInterceptor { private readonly MatcherObserver matcherObserver; private int creationTimestamp; - private Invocation invocation; + private IInvocation invocation; private int invocationTimestamp; private object returnValue; @@ -251,7 +251,7 @@ public Recorder(MatcherObserver matcherObserver) this.creationTimestamp = this.matcherObserver.GetNextTimestamp(); } - public Invocation Invocation => this.invocation; + public IInvocation Invocation => this.invocation; public IEnumerable Matches { @@ -264,7 +264,7 @@ public IEnumerable Matches public Recorder Next => (Awaitable.TryGetResultRecursive(this.returnValue) as IProxy)?.Interceptor as Recorder; - public void Intercept(Invocation invocation) + public void Intercept(IInvocation invocation) { var returnType = invocation.Method.ReturnType; diff --git a/src/Moq/Async/IAwaitableFactory.cs b/src/Moq/Async/IAwaitableFactory.cs index fb87828bb..550be258b 100644 --- a/src/Moq/Async/IAwaitableFactory.cs +++ b/src/Moq/Async/IAwaitableFactory.cs @@ -7,18 +7,32 @@ namespace Moq.Async { - internal interface IAwaitableFactory + /// + /// + public interface IAwaitableFactory { + /// + /// Type ResultType { get; } + /// + /// object CreateCompleted(object result = null); + /// + /// object CreateFaulted(Exception exception); + /// + /// object CreateFaulted(IEnumerable exceptions); + /// + /// Expression CreateResultExpression(Expression awaitableExpression); + /// + /// bool TryGetResult(object awaitable, out object result); } } diff --git a/src/Moq/AutoImplementedPropertyGetterSetup.cs b/src/Moq/AutoImplementedPropertyGetterSetup.cs index 83765c82a..c9bb3704c 100644 --- a/src/Moq/AutoImplementedPropertyGetterSetup.cs +++ b/src/Moq/AutoImplementedPropertyGetterSetup.cs @@ -24,7 +24,7 @@ public AutoImplementedPropertyGetterSetup(Mock mock, LambdaExpression originalEx this.MarkAsVerifiable(); } - protected override void ExecuteCore(Invocation invocation) + protected override void ExecuteCore(IInvocation invocation) { invocation.ReturnValue = this.getter.Invoke(); } diff --git a/src/Moq/AutoImplementedPropertySetterSetup.cs b/src/Moq/AutoImplementedPropertySetterSetup.cs index 17f83da6b..694e519c8 100644 --- a/src/Moq/AutoImplementedPropertySetterSetup.cs +++ b/src/Moq/AutoImplementedPropertySetterSetup.cs @@ -23,7 +23,7 @@ public AutoImplementedPropertySetterSetup(Mock mock, LambdaExpression originalEx this.MarkAsVerifiable(); } - protected override void ExecuteCore(Invocation invocation) + protected override void ExecuteCore(IInvocation invocation) { this.setter.Invoke(invocation.Arguments[0]); } diff --git a/src/Moq/Behavior.cs b/src/Moq/Behavior.cs index b9d87ca26..7dcc0fece 100644 --- a/src/Moq/Behavior.cs +++ b/src/Moq/Behavior.cs @@ -9,6 +9,6 @@ protected Behavior() { } - public abstract void Execute(Invocation invocation); + public abstract void Execute(IInvocation invocation); } } diff --git a/src/Moq/Behaviors/Callback.cs b/src/Moq/Behaviors/Callback.cs index 8addfdea8..5b93abc82 100644 --- a/src/Moq/Behaviors/Callback.cs +++ b/src/Moq/Behaviors/Callback.cs @@ -17,7 +17,7 @@ public Callback(Action callback) this.callback = callback; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { this.callback.Invoke(invocation); } diff --git a/src/Moq/Behaviors/LimitInvocationCount.cs b/src/Moq/Behaviors/LimitInvocationCount.cs index e1c3e086a..4a2f7db48 100644 --- a/src/Moq/Behaviors/LimitInvocationCount.cs +++ b/src/Moq/Behaviors/LimitInvocationCount.cs @@ -21,7 +21,7 @@ public void Reset() this.count = 0; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { ++this.count; diff --git a/src/Moq/Behaviors/NoOp.cs b/src/Moq/Behaviors/NoOp.cs index 429cfbdef..ee0b135eb 100644 --- a/src/Moq/Behaviors/NoOp.cs +++ b/src/Moq/Behaviors/NoOp.cs @@ -11,7 +11,7 @@ private NoOp() { } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { } } diff --git a/src/Moq/Behaviors/RaiseEvent.cs b/src/Moq/Behaviors/RaiseEvent.cs index 7d1c8c5ea..c2c39e086 100644 --- a/src/Moq/Behaviors/RaiseEvent.cs +++ b/src/Moq/Behaviors/RaiseEvent.cs @@ -26,7 +26,7 @@ public RaiseEvent(Mock mock, LambdaExpression expression, Delegate eventArgsFunc this.eventArgsParams = eventArgsParams; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { object[] args; diff --git a/src/Moq/Behaviors/ReturnBase.cs b/src/Moq/Behaviors/ReturnBase.cs index bafaf659c..5bf5cd297 100644 --- a/src/Moq/Behaviors/ReturnBase.cs +++ b/src/Moq/Behaviors/ReturnBase.cs @@ -11,7 +11,7 @@ private ReturnBase() { } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { invocation.ReturnValue = invocation.CallBase(); } diff --git a/src/Moq/Behaviors/ReturnBaseOrDefaultValue.cs b/src/Moq/Behaviors/ReturnBaseOrDefaultValue.cs index d39a24acf..c7e17ab84 100644 --- a/src/Moq/Behaviors/ReturnBaseOrDefaultValue.cs +++ b/src/Moq/Behaviors/ReturnBaseOrDefaultValue.cs @@ -17,7 +17,7 @@ public ReturnBaseOrDefaultValue(Mock mock) this.mock = mock; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { Debug.Assert(invocation.Method != null); Debug.Assert(invocation.Method.ReturnType != null); diff --git a/src/Moq/Behaviors/ReturnComputedValue.cs b/src/Moq/Behaviors/ReturnComputedValue.cs index d59c844c6..1eaf690ba 100644 --- a/src/Moq/Behaviors/ReturnComputedValue.cs +++ b/src/Moq/Behaviors/ReturnComputedValue.cs @@ -17,7 +17,7 @@ public ReturnComputedValue(Func valueFactory) this.valueFactory = valueFactory; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { invocation.ReturnValue = this.valueFactory.Invoke(invocation); } diff --git a/src/Moq/Behaviors/ReturnValue.cs b/src/Moq/Behaviors/ReturnValue.cs index ad1446254..51022f96f 100644 --- a/src/Moq/Behaviors/ReturnValue.cs +++ b/src/Moq/Behaviors/ReturnValue.cs @@ -14,7 +14,7 @@ public ReturnValue(object value) public object Value => this.value; - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { invocation.ReturnValue = this.value; } diff --git a/src/Moq/Behaviors/ThrowException.cs b/src/Moq/Behaviors/ThrowException.cs index 478645734..593801763 100644 --- a/src/Moq/Behaviors/ThrowException.cs +++ b/src/Moq/Behaviors/ThrowException.cs @@ -17,7 +17,7 @@ public ThrowException(Exception exception) this.exception = exception; } - public override void Execute(Invocation invocation) + public override void Execute(IInvocation invocation) { throw this.exception; } diff --git a/src/Moq/Extensions.cs b/src/Moq/Extensions.cs index 7d745fc50..50bce58df 100644 --- a/src/Moq/Extensions.cs +++ b/src/Moq/Extensions.cs @@ -481,7 +481,7 @@ public static Setup TryFind(this IEnumerable setups, InvocationShape expe return setups.FirstOrDefault(setup => setup.Expectation.Equals(expectation)); } - public static Setup TryFind(this IEnumerable setups, Invocation invocation) + public static Setup TryFind(this IEnumerable setups, IInvocation invocation) { return setups.FirstOrDefault(setup => setup.Matches(invocation)); } diff --git a/src/Moq/IInvocation.cs b/src/Moq/IInvocation.cs index cd9e6a21b..41cc99e01 100644 --- a/src/Moq/IInvocation.cs +++ b/src/Moq/IInvocation.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using Moq.Async; namespace Moq { @@ -17,16 +18,24 @@ public interface IInvocation /// MethodInfo Method { get; } + /// + /// + MethodInfo MethodImplementation { get; } + /// /// Gets the arguments of the invocation. /// - IReadOnlyList Arguments { get; } + object[] Arguments { get; } /// /// Gets the setup that matched this invocation (or if there was no matching setup). /// ISetup MatchingSetup { get; } + /// + /// + Type ProxyType { get; } + /// /// Gets whether this invocation was successfully verified by any of the various `Verify` methods. /// @@ -35,11 +44,23 @@ public interface IInvocation /// /// The value being returned for a non-void method if no exception was thrown. /// - object ReturnValue { get; } + object ReturnValue { get; set; } /// /// Optional exception if the method invocation results in an exception being thrown. /// - Exception Exception { get; } + Exception Exception { get; set; } + + /// + /// + void MarkAsMatchedBy(ISetup setup); + + /// + /// + void ConvertResultToAwaitable(IAwaitableFactory awaitableFactory); + + /// + /// + object CallBase(); } } \ No newline at end of file diff --git a/src/Moq/InnerMockSetup.cs b/src/Moq/InnerMockSetup.cs index 8da6d04fd..79ec7bf63 100644 --- a/src/Moq/InnerMockSetup.cs +++ b/src/Moq/InnerMockSetup.cs @@ -22,7 +22,7 @@ public InnerMockSetup(Expression originalExpression, Mock mock, InvocationShape this.MarkAsVerifiable(); } - protected override void ExecuteCore(Invocation invocation) + protected override void ExecuteCore(IInvocation invocation) { invocation.ReturnValue = this.returnValue; } diff --git a/src/Moq/Interception/IInterceptor.cs b/src/Moq/Interception/IInterceptor.cs index 6eb0ba566..de059e813 100644 --- a/src/Moq/Interception/IInterceptor.cs +++ b/src/Moq/Interception/IInterceptor.cs @@ -7,8 +7,10 @@ namespace Moq /// This role interface represents a 's ability to intercept method invocations for its . /// It is meant for use by . /// - internal interface IInterceptor + public interface IInterceptor { - void Intercept(Invocation invocation); + /// + /// + void Intercept(IInvocation invocation); } } diff --git a/src/Moq/Interception/InterceptionAspects.cs b/src/Moq/Interception/InterceptionAspects.cs index 114c2b3dd..6b459dc12 100644 --- a/src/Moq/Interception/InterceptionAspects.cs +++ b/src/Moq/Interception/InterceptionAspects.cs @@ -13,7 +13,7 @@ namespace Moq { internal static class HandleWellKnownMethods { - private static Dictionary> specialMethods = new Dictionary>() + private static Dictionary> specialMethods = new Dictionary>() { ["Equals"] = HandleEquals, ["Finalize"] = HandleFinalize, @@ -22,13 +22,13 @@ internal static class HandleWellKnownMethods ["ToString"] = HandleToString, }; - public static bool Handle(Invocation invocation, Mock mock) + public static bool Handle(IInvocation invocation, Mock mock) { return specialMethods.TryGetValue(invocation.Method.Name, out var handler) && handler.Invoke(invocation, mock); } - private static bool HandleEquals(Invocation invocation, Mock mock) + private static bool HandleEquals(IInvocation invocation, Mock mock) { if (IsObjectMethod(invocation.Method) && !mock.MutableSetups.Any(c => IsObjectMethod(c.Method, "Equals"))) { @@ -41,12 +41,12 @@ private static bool HandleEquals(Invocation invocation, Mock mock) } } - private static bool HandleFinalize(Invocation invocation, Mock mock) + private static bool HandleFinalize(IInvocation invocation, Mock mock) { return IsFinalizer(invocation.Method); } - private static bool HandleGetHashCode(Invocation invocation, Mock mock) + private static bool HandleGetHashCode(IInvocation invocation, Mock mock) { // Only if there is no corresponding setup for `GetHashCode()` if (IsObjectMethod(invocation.Method) && !mock.MutableSetups.Any(c => IsObjectMethod(c.Method, "GetHashCode"))) @@ -60,7 +60,7 @@ private static bool HandleGetHashCode(Invocation invocation, Mock mock) } } - private static bool HandleToString(Invocation invocation, Mock mock) + private static bool HandleToString(IInvocation invocation, Mock mock) { // Only if there is no corresponding setup for `ToString()` if (IsObjectMethod(invocation.Method) && !mock.MutableSetups.Any(c => IsObjectMethod(c.Method, "ToString"))) @@ -74,7 +74,7 @@ private static bool HandleToString(Invocation invocation, Mock mock) } } - private static bool HandleMockGetter(Invocation invocation, Mock mock) + private static bool HandleMockGetter(IInvocation invocation, Mock mock) { if (typeof(IMocked).IsAssignableFrom(invocation.Method.DeclaringType)) { @@ -99,7 +99,7 @@ private static bool IsFinalizer(MethodInfo method) internal static class FindAndExecuteMatchingSetup { - public static bool Handle(Invocation invocation, Mock mock) + public static bool Handle(IInvocation invocation, Mock mock) { var matchingSetup = mock.MutableSetups.FindMatchFor(invocation); if (matchingSetup != null) @@ -116,7 +116,7 @@ public static bool Handle(Invocation invocation, Mock mock) internal static class HandleEventSubscription { - public static bool Handle(Invocation invocation, Mock mock) + public static bool Handle(IInvocation invocation, Mock mock) { const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly; @@ -170,7 +170,7 @@ public static bool Handle(Invocation invocation, Mock mock) internal static class RecordInvocation { - public static void Handle(Invocation invocation, Mock mock) + public static void Handle(IInvocation invocation, Mock mock) { // Save to support Verify[expression] pattern. mock.MutableInvocations.Add(invocation); @@ -179,7 +179,7 @@ public static void Handle(Invocation invocation, Mock mock) internal static class Return { - public static void Handle(Invocation invocation, Mock mock) + public static void Handle(IInvocation invocation, Mock mock) { new ReturnBaseOrDefaultValue(mock).Execute(invocation); } @@ -189,7 +189,7 @@ internal static class HandleAutoSetupProperties { private static readonly int AccessorPrefixLength = "?et_".Length; // get_ or set_ - public static bool Handle(Invocation invocation, Mock mock) + public static bool Handle(IInvocation invocation, Mock mock) { if (mock.AutoSetupPropertiesDefaultValueProvider == null) { @@ -278,7 +278,7 @@ private static LambdaExpression GetPropertyExpression(Type mockType, PropertyInf internal static class FailForStrictMock { - public static void Handle(Invocation invocation, Mock mock) + public static void Handle(IInvocation invocation, Mock mock) { if (mock.Behavior == MockBehavior.Strict) { diff --git a/src/Moq/Interception/Mock.cs b/src/Moq/Interception/Mock.cs index 20baedbde..f4c8e8e7f 100644 --- a/src/Moq/Interception/Mock.cs +++ b/src/Moq/Interception/Mock.cs @@ -5,7 +5,7 @@ namespace Moq { partial class Mock : IInterceptor { - void IInterceptor.Intercept(Invocation invocation) + void IInterceptor.Intercept(IInvocation invocation) { if (HandleWellKnownMethods.Handle(invocation, this)) { diff --git a/src/Moq/Invocation.cs b/src/Moq/Invocation.cs index b859d11f0..169917711 100644 --- a/src/Moq/Invocation.cs +++ b/src/Moq/Invocation.cs @@ -18,7 +18,7 @@ internal abstract class Invocation : IInvocation private MethodInfo methodImplementation; private readonly Type proxyType; private object result; - private Setup matchingSetup; + private ISetup matchingSetup; private bool verified; /// @@ -65,8 +65,6 @@ public MethodInfo MethodImplementation /// public object[] Arguments => this.arguments; - IReadOnlyList IInvocation.Arguments => this.arguments; - public ISetup MatchingSetup => this.matchingSetup; public Type ProxyType => this.proxyType; @@ -109,9 +107,9 @@ public void ConvertResultToAwaitable(IAwaitableFactory awaitableFactory) /// Calls the method implementation /// and returns its return value (or for methods). /// - protected internal abstract object CallBase(); + public abstract object CallBase(); - internal void MarkAsMatchedBy(Setup setup) + public void MarkAsMatchedBy(ISetup setup) { Debug.Assert(this.matchingSetup == null); @@ -120,7 +118,7 @@ internal void MarkAsMatchedBy(Setup setup) internal void MarkAsVerified() => this.verified = true; - internal void MarkAsVerifiedIfMatchedBy(Func predicate) + internal void MarkAsVerifiedIfMatchedBy(Func predicate) { if (this.matchingSetup != null && predicate(this.matchingSetup)) { diff --git a/src/Moq/InvocationCollection.cs b/src/Moq/InvocationCollection.cs index 27f705d74..3ab8340e8 100644 --- a/src/Moq/InvocationCollection.cs +++ b/src/Moq/InvocationCollection.cs @@ -10,7 +10,7 @@ namespace Moq { internal sealed class InvocationCollection : IInvocationList { - private Invocation[] invocations; + private IInvocation[] invocations; private int capacity = 0; private int count = 0; @@ -52,7 +52,7 @@ public IInvocation this[int index] } } - public void Add(Invocation invocation) + public void Add(IInvocation invocation) { lock (this.invocationsLock) { @@ -99,7 +99,7 @@ public Invocation[] ToArray() } } - public Invocation[] ToArray(Func predicate) + public IInvocation[] ToArray(Func predicate) { lock (this.invocationsLock) { @@ -108,7 +108,7 @@ public Invocation[] ToArray(Func predicate) return new Invocation[0]; } - var result = new List(this.count); + var result = new List(this.count); for (var i = 0; i < this.count; i++) { @@ -126,7 +126,7 @@ public Invocation[] ToArray(Func predicate) public IEnumerator GetEnumerator() { // Take local copies of collection and count so they are isolated from changes by other threads. - Invocation[] collection; + IInvocation[] collection; int count; lock (this.invocationsLock) diff --git a/src/Moq/InvocationShape.cs b/src/Moq/InvocationShape.cs index 2c9a78768..1ea56ca9f 100644 --- a/src/Moq/InvocationShape.cs +++ b/src/Moq/InvocationShape.cs @@ -26,7 +26,7 @@ namespace Moq /// internal sealed class InvocationShape : IEquatable { - public static InvocationShape CreateFrom(Invocation invocation) + public static InvocationShape CreateFrom(IInvocation invocation) { var method = invocation.Method; @@ -118,7 +118,7 @@ public void Deconstruct(out LambdaExpression expression, out MethodInfo method, arguments = this.Arguments; } - public bool IsMatch(Invocation invocation) + public bool IsMatch(IInvocation invocation) { if (invocation.Method != this.Method && !this.IsOverride(invocation)) { @@ -138,7 +138,7 @@ public bool IsMatch(Invocation invocation) return true; } - public void SetupEvaluatedSuccessfully(Invocation invocation) + public void SetupEvaluatedSuccessfully(IInvocation invocation) { var arguments = invocation.Arguments; var parameterTypes = invocation.Method.GetParameterTypes(); @@ -148,7 +148,7 @@ public void SetupEvaluatedSuccessfully(Invocation invocation) } } - private bool IsOverride(Invocation invocation) + private bool IsOverride(IInvocation invocation) { Debug.Assert(invocation.Method != this.Method); diff --git a/src/Moq/MethodCall.cs b/src/Moq/MethodCall.cs index 02209c4e4..70d0f2da6 100644 --- a/src/Moq/MethodCall.cs +++ b/src/Moq/MethodCall.cs @@ -82,7 +82,7 @@ private static string GetUserCodeCallSite() return null; } - protected override void ExecuteCore(Invocation invocation) + protected override void ExecuteCore(IInvocation invocation) { this.limitInvocationCount?.Execute(invocation); diff --git a/src/Moq/MockException.cs b/src/Moq/MockException.cs index d1f62356f..391dc8c11 100644 --- a/src/Moq/MockException.cs +++ b/src/Moq/MockException.cs @@ -130,7 +130,7 @@ internal static MockException NoMatchingCalls( /// /// Returns the exception to be thrown when a strict mock has no setup corresponding to the specified invocation. /// - internal static MockException NoSetup(Invocation invocation) + internal static MockException NoSetup(IInvocation invocation) { return new MockException( MockExceptionReasons.NoSetup, @@ -145,7 +145,7 @@ internal static MockException NoSetup(Invocation invocation) /// /// Returns the exception to be thrown when a strict mock has no setup that provides a return value for the specified invocation. /// - internal static MockException ReturnValueRequired(Invocation invocation) + internal static MockException ReturnValueRequired(IInvocation invocation) { return new MockException( MockExceptionReasons.ReturnValueRequired, @@ -214,7 +214,7 @@ internal static MockException Combined(IEnumerable errors, string /// /// Returns the exception to be thrown when finds invocations that have not been verified. /// - internal static MockException UnverifiedInvocations(Mock mock, IEnumerable invocations) + internal static MockException UnverifiedInvocations(Mock mock, IEnumerable invocations) { var message = new StringBuilder(); diff --git a/src/Moq/ProxyFactories/CastleProxyFactory.cs b/src/Moq/ProxyFactories/CastleProxyFactory.cs index bf4ece1ef..8e2e3a6e7 100644 --- a/src/Moq/ProxyFactories/CastleProxyFactory.cs +++ b/src/Moq/ProxyFactories/CastleProxyFactory.cs @@ -122,7 +122,7 @@ internal Invocation(Castle.DynamicProxy.IInvocation underlying) : base(underlyin this.underlying = underlying; } - protected internal override object CallBase() + public override object CallBase() { Debug.Assert(this.underlying != null); diff --git a/src/Moq/ProxyFactories/InterfaceProxy.cs b/src/Moq/ProxyFactories/InterfaceProxy.cs index 5dc94b381..09ed11731 100644 --- a/src/Moq/ProxyFactories/InterfaceProxy.cs +++ b/src/Moq/ProxyFactories/InterfaceProxy.cs @@ -68,7 +68,7 @@ public Invocation(Type proxyType, MethodInfo method) { } - protected internal override object CallBase() + public override object CallBase() { throw new NotSupportedException(); } diff --git a/src/Moq/ProxyFactories/ProxyFactory.cs b/src/Moq/ProxyFactories/ProxyFactory.cs index c925780c2..bab560eef 100644 --- a/src/Moq/ProxyFactories/ProxyFactory.cs +++ b/src/Moq/ProxyFactories/ProxyFactory.cs @@ -6,17 +6,25 @@ namespace Moq { - internal abstract class ProxyFactory + /// + /// + public abstract class ProxyFactory { /// /// Gets the global instance used by Moq. /// - public static ProxyFactory Instance { get; } = new CastleProxyFactory(); + public static ProxyFactory Instance { get; set; } = new CastleProxyFactory(); + /// + /// public abstract object CreateProxy(Type mockType, IInterceptor interceptor, Type[] interfaces, object[] arguments); + /// + /// public abstract bool IsMethodVisible(MethodInfo method, out string messageIfNotVisible); + /// + /// public abstract bool IsTypeVisible(Type type); } } diff --git a/src/Moq/SequenceSetup.cs b/src/Moq/SequenceSetup.cs index 8851046ab..c53c0e6f3 100644 --- a/src/Moq/SequenceSetup.cs +++ b/src/Moq/SequenceSetup.cs @@ -28,7 +28,7 @@ public void AddBehavior(Behavior behavior) this.behaviors.Enqueue(behavior); } - protected override void ExecuteCore(Invocation invocation) + protected override void ExecuteCore(IInvocation invocation) { if (this.behaviors.TryDequeue(out var behavior)) { diff --git a/src/Moq/Setup.cs b/src/Moq/Setup.cs index 6a72d7949..f37e73848 100644 --- a/src/Moq/Setup.cs +++ b/src/Moq/Setup.cs @@ -52,7 +52,7 @@ protected Setup(Expression originalExpression, Mock mock, InvocationShape expect public bool IsMatched => (this.flags & Flags.Matched) != 0; - public void Execute(Invocation invocation) + public void Execute(IInvocation invocation) { // update this setup: this.flags |= Flags.Matched; @@ -86,7 +86,7 @@ public void Execute(Invocation invocation) } } - protected abstract void ExecuteCore(Invocation invocation); + protected abstract void ExecuteCore(IInvocation invocation); /// /// Attempts to get this setup's return value without invoking user code @@ -110,12 +110,12 @@ public void MarkAsVerifiable() this.flags |= Flags.Verifiable; } - public bool Matches(Invocation invocation) + public bool Matches(IInvocation invocation) { return this.expectation.IsMatch(invocation) && (this.Condition == null || this.Condition.IsTrue); } - public virtual void SetOutParameters(Invocation invocation) + public virtual void SetOutParameters(IInvocation invocation) { } diff --git a/src/Moq/SetupCollection.cs b/src/Moq/SetupCollection.cs index 4edfaa05a..f5b90fe92 100644 --- a/src/Moq/SetupCollection.cs +++ b/src/Moq/SetupCollection.cs @@ -109,7 +109,7 @@ public void Clear() } } - public Setup FindMatchFor(Invocation invocation) + public Setup FindMatchFor(IInvocation invocation) { // Fast path (no `lock`) when there are no setups: if (this.setups.Count == 0) diff --git a/src/Moq/SetupWithOutParameterSupport.cs b/src/Moq/SetupWithOutParameterSupport.cs index 3f2793418..44789a243 100644 --- a/src/Moq/SetupWithOutParameterSupport.cs +++ b/src/Moq/SetupWithOutParameterSupport.cs @@ -23,7 +23,7 @@ protected SetupWithOutParameterSupport(Expression originalExpression, Mock mock, this.outValues = GetOutValues(expectation.Arguments, expectation.Method.GetParameters()); } - public sealed override void SetOutParameters(Invocation invocation) + public sealed override void SetOutParameters(IInvocation invocation) { if (this.outValues != null) { diff --git a/tests/Moq.Tests/InterceptorFixture.cs b/tests/Moq.Tests/InterceptorFixture.cs index 807048fee..2115a73ff 100644 --- a/tests/Moq.Tests/InterceptorFixture.cs +++ b/tests/Moq.Tests/InterceptorFixture.cs @@ -63,7 +63,7 @@ public Echo(object returnValue) this.returnValue = returnValue; } - public void Intercept(Invocation invocation) + public void Intercept(IInvocation invocation) { invocation.ReturnValue = this.returnValue; }