From 0e3eaf3d7cb2dca83e927fd42510be611ec53548 Mon Sep 17 00:00:00 2001 From: stakx Date: Mon, 19 Jun 2017 19:23:47 +0200 Subject: [PATCH] Fix interface bug introduced by 162a543 Commit 162a543 introduced a bug by handing over too many interfaces to Castle's `ProxyGenerator.CreateClassProxy` method. The intention behind that commit apparently was to enable `mock.As` even after `mock.Object` has already been called. That change unfortunately also caused mocked class' methods that im- plement an interface method to no longer be mocked correctly. This commit fixes this problem by ensuring that the "internally implemented" interfaces are not explicitly passed to `.CreateClass- Proxy` (like it used to be done previously). --- Source/Mock.Generic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Mock.Generic.cs b/Source/Mock.Generic.cs index 9bc45c393..1b4df952a 100644 --- a/Source/Mock.Generic.cs +++ b/Source/Mock.Generic.cs @@ -213,7 +213,7 @@ private void InitializeInstance() this.instance = (T)proxyFactory.CreateProxy( typeof(T), this.Interceptor, - this.ImplementedInterfaces.ToArray(), + this.ImplementedInterfaces.Skip(this.InternallyImplementedInterfaceCount - 1).ToArray(), this.constructorArguments); } });