forked from ayende/rhino-mocks
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failing tests: stub returning delegate twice
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
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