Skip to content

Commit 3ef9732

Browse files
committed
Prevent early initialization of mock from checking for delegate mocks.
Fixes issue #54
1 parent 3bffb14 commit 3ef9732

File tree

5 files changed

+2427
-2374
lines changed

5 files changed

+2427
-2374
lines changed

Source/ExpressionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ internal static CallInfo GetCallInfo(this LambdaExpression expression, Mock mock
238238
{
239239
Guard.NotNull(() => expression, expression);
240240

241-
if (mock.DelegateInterfaceMethod != null)
241+
if (mock.IsDelegateMock)
242242
{
243243
// We're a mock for a delegate, so this call can only
244244
// possibly be the result of invoking the delegate.

Source/Mock.Generic.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,16 @@ private void CheckParameters()
139139
get { return (T)base.Object; }
140140
}
141141

142+
internal override bool IsDelegateMock
143+
{
144+
get { return typeof(T).IsDelegate(); }
145+
}
146+
142147
private void InitializeInstance()
143148
{
144149
PexProtector.Invoke(() =>
145150
{
146-
if (typeof(T).IsDelegate())
151+
if (this.IsDelegateMock)
147152
{
148153
// We're mocking a delegate.
149154
// Firstly, get/create an interface with a method whose signature

0 commit comments

Comments
 (0)