Skip to content

Commit

Permalink
Failing tests: stub returning delegate twice
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Sep 19, 2010
1 parent d458e60 commit b2f15b6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Rhino.Mocks.Tests/FieldsProblem/FieldProblem_KeithD.cs
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; }
}
}
1 change: 1 addition & 0 deletions Rhino.Mocks.Tests/Rhino.Mocks.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit b2f15b6

Please sign in to comment.