Using the new Rhino Mocks 3.5 Arrange / Act / Assert (AAA) testing style, I am having trouble writing a test.
I have a method that calls a method in a repository class. ActivateFoo, where my Foo object has an IsActive property. The result of the ActivateFoo object should change the property.
Here is a sample code:
[TestMethod]
public void Should_update_foo_to_active_inside_of_repository()
{
var repo = MockRepository.GenerateMock<IRepository>();
var foo = new Foo() { ID = 1, IsActive = false };
var target = new Presenter(repo);
repo.Expect(x => x.ActivateFoo(foo)).Return(true);
target.Activate(foo);
Assert.IsTrue(foo.IsActive);
repo.VerifyAllExpectations();
}
I assume that the key piece of code will be inbetween "ActivateFoo (foo))". and "Return (true)".
One moment to clarify how the chain of method elements works behind the scenes. If there is code written in the line that I expect, does it matter if it's after Return () or earlier? (unless, of course, the solution does not use MethodOptions Expect overload or something else).
Thanks in advance for your help.