I'm trying to use Rhinomocks 3.5 and the new lambda notation to mock some tests. I've read this, but have so many more questions. Are there any complete examples out there, especially for a MVC type of architecture?
For example what is the best way to mock this.
public void OnAuthenticateUnitAccount()
{
if(AuthenticateUnitAccount != null)
{
int accountID = int.Parse(_view.GetAccountID());
int securityCode = int.Parse(_view.GetSecurityCode());
AuthenticateUnitAccount(accountID, securityCode);
}
}
There is a view interface and a presenter interface. It's calling an event on the controller.
What I came up with is this.
[TestMethod()]
public void OnAuthenticateUnitAccountTest()
{
IAuthenticationView view = MockRepository.GenerateStub<IAuthenticationView>();
IAuthenticationPresenter target = MockRepository.GenerateMock<IAuthenticationPresenter>();
target.Raise(x => x.AuthenticateUnitAccount += null, view.GetPlayerID(), view.GetSecurityCode());
target.VerifyAllExpectations();
}
It passes but I don't know if it is correct.
And yes we are doing the tests after we developed...it needed to be done quickly.