Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from FelicePollano/dev
refactored Interceptor.Intercept to use a set of strategies. .
- Loading branch information
Showing
5 changed files
with
372 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Moq.Proxy; | ||
|
||
namespace Moq | ||
{ | ||
|
||
internal enum InterceptionAction | ||
{ | ||
Continue,Stop | ||
} | ||
internal interface IInterceptStrategy | ||
{ | ||
/// <summary> | ||
/// Handle interception | ||
/// </summary> | ||
/// <param name="invocation">the current invocation context</param> | ||
/// <param name="ctx">shared data among the strategies during an interception</param> | ||
/// <returns>true if further interception has to be processed, otherwise false</returns> | ||
InterceptionAction HandleIntercept(ICallContext invocation, InterceptStrategyContext ctx); | ||
|
||
} | ||
|
||
internal class InterceptStrategyContext | ||
{ | ||
public InterceptStrategyContext(Mock Mock | ||
, Type targetType | ||
, Dictionary<string, List<Delegate>> invocationLists | ||
, List<ICallContext> actualInvocations | ||
, MockBehavior behavior | ||
, List<IProxyCall> orderedCalls | ||
) | ||
{ | ||
this.Behavior = behavior; | ||
this.Mock = Mock; | ||
this.InvocationLists = invocationLists; | ||
this.ActualInvocations = actualInvocations; | ||
this.TargetType = targetType; | ||
this.OrderedCalls = orderedCalls; | ||
} | ||
public Mock Mock {get;private set;} | ||
public Type TargetType { get; private set; } | ||
public Dictionary<string, List<Delegate>> InvocationLists { get; private set; } | ||
public List<ICallContext> ActualInvocations { get; private set; } | ||
public MockBehavior Behavior { get; private set; } | ||
public List<IProxyCall> OrderedCalls { get; private set; } | ||
public IProxyCall CurrentCall { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.