Created
July 20, 2009 17:39
-
-
Save agross/150466 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Index: Rhino.Mocks.Tests/FieldsProblem/FieldProblem_Alex.cs | |
=================================================================== | |
--- Rhino.Mocks.Tests/FieldsProblem/FieldProblem_Alex.cs (Revision 0) | |
+++ Rhino.Mocks.Tests/FieldsProblem/FieldProblem_Alex.cs (Revision 0) | |
@@ -0,0 +1,43 @@ | |
+using System; | |
+using MbUnit.Framework; | |
+ | |
+namespace Rhino.Mocks.Tests.FieldsProblem | |
+{ | |
+ [TestFixture] | |
+ public class FieldProblem__Alex | |
+ { | |
+ [Test] | |
+ public void CanMockMethodWithEnvironmentPermissions() | |
+ { | |
+ var withInt = MockRepository.GenerateStub<IDoSomethingWith<int>>(); | |
+ var withString = MockRepository.GenerateStub<IDoSomethingWith<string>>(); | |
+ | |
+ var doer = MockRepository.GenerateStub<IDoSomethingTwice>(); | |
+ | |
+ // Fails | |
+ new Doer(doer, withInt, withString); | |
+ } | |
+ } | |
+ | |
+ public interface IDoSomethingWith<T> | |
+ { | |
+ Action<T> DoSomething | |
+ { | |
+ get; | |
+ set; | |
+ } | |
+ } | |
+ | |
+ public interface IDoSomethingTwice : IDoSomethingWith<int>, IDoSomethingWith<string> | |
+ { | |
+ } | |
+ | |
+ public class Doer | |
+ { | |
+ public Doer(IDoSomethingTwice doer, IDoSomethingWith<int> withInt, IDoSomethingWith<string> withString) | |
+ { | |
+ ((IDoSomethingWith<int>)doer).DoSomething += x => withInt.DoSomething(x); | |
+ ((IDoSomethingWith<string>)doer).DoSomething += x => withString.DoSomething(x); | |
+ } | |
+ } | |
+} | |
Index: Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj | |
=================================================================== | |
--- Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj (Revision 2205) | |
+++ Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj (Arbeitskopie) | |
@@ -150,6 +150,7 @@ | |
<Compile Include="DotNet35Tests.cs" /> | |
<Compile Include="ExtendingRhinoMocks.cs" /> | |
<Compile Include="ExtendingRhinoMocks2.cs" /> | |
+ <Compile Include="FieldsProblem\FieldProblem_ Alex.cs" /> | |
<Compile Include="FieldsProblem\FieldProblem_ Sean.cs" /> | |
<Compile Include="FieldsProblem\FieldProblem_75_MockingExpcetion.cs" /> | |
<Compile Include="FieldsProblem\FieldProblem_Adam.cs" /> | |
Index: Rhino.Mocks/Impl/ProxyInstance.cs | |
=================================================================== | |
--- Rhino.Mocks/Impl/ProxyInstance.cs (Revision 2205) | |
+++ Rhino.Mocks/Impl/ProxyInstance.cs (Arbeitskopie) | |
@@ -327,11 +327,12 @@ | |
private static string GenerateKey(MethodInfo method, object[] args) | |
{ | |
+ var baseName = method.DeclaringType.FullName + method.Name.Substring(4); | |
if ((method.Name.StartsWith("get_") && args.Length == 0) || | |
(method.Name.StartsWith("set_") && args.Length == 1)) | |
- return method.Name.Substring(4); | |
+ return baseName; | |
StringBuilder sb = new StringBuilder(); | |
- sb.Append(method.Name.Substring(4)); | |
+ sb.Append(baseName); | |
int len = args.Length; | |
if (method.Name.StartsWith("set_")) | |
len--; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment