Permalink
Browse files

Failing tests: stub returning delegate twice

  • Loading branch information...
1 parent d458e60 commit b2f15b6d173f92583edc8248c4881a928e585c34 @dahlbyk dahlbyk committed Sep 19, 2010
@@ -0,0 +1,41 @@
+namespace Rhino.Mocks.Tests.FieldsProblem
+{
+ using System;
+ using Xunit;
+
+ public class FieldProblem_KeithD
+ {
+ [Fact]
+ public void CanStubReturningAnonymousDelegateTwice()
+ {
+ var foo = MockRepository.GenerateMock<IFoo>();
+
+ foo.Stub(x => x.Bar(0)).Return(() => 2);
+ foo.Stub(x => x.Bar(1)).Return(() => 4);
+
+ Assert.Equal(2, foo.Bar(0)());
+ Assert.Equal(4, foo.Bar(1)());
+ }
+
+ [Fact]
+ public void CanStubReturningNonAnonymousDelegateTwice()
+ {
+ var foo = MockRepository.GenerateMock<IFoo>();
+
+ foo.Stub(x => x.Bar(0)).Return(Return2);
+ foo.Stub(x => x.Bar(1)).Return(Return4);
+
+ Assert.Equal(2, foo.Bar(0)());
+ Assert.Equal(4, foo.Bar(1)());
+ }
+
+ public interface IFoo
+ {
+ Func<int> Bar(int baz);
+ }
+
+ private static int Return2() { return 2; }
+
+ private static int Return4() { return 4; }
+ }
+}
@@ -175,6 +175,7 @@
<Compile Include="FieldsProblem\FieldProblem_Alex.cs" />
<Compile Include="FieldsProblem\FieldProblem_Bill.cs" />
<Compile Include="FieldsProblem\FieldProblem_JPBoodhoo.cs" />
+ <Compile Include="FieldsProblem\FieldProblem_KeithD.cs" />
<Compile Include="MethodProblems\MethodProblem_JPBoodhoo.cs" />
<Compile Include="PartialMockTestsAAA.cs" />
<Compile Include="MultiMocksWithAAA.cs" />

0 comments on commit b2f15b6

Please sign in to comment.