The condition you assert in your test does not seem to have much sense. Your code seems to test that the mock instance in _dalActivityLog returns the constant that you've set up.
In that test you should test the code of the function Login
, not the _dalActivityLog
implementation. Thus, you should check that _dalActivityLog.Save is called with the right parameter passed.
I suppose that _dalActivityLog
is an instance of a class that implements an interface that you haven't specified in your question. Let's call it IActivityLog
. Then you should set up a mock instance of it in your test code.
IActivityLog logMock = MockRepository.GenerateStub<IActivityLog>();
Then you inject somehow this mock instance into the instance of the class the has the Login method (via constructor or property).
Then call your Login
method and pass there an instance of User
.
Then you make the assertion about the _dalActivityLog.Save call, like the one below.
logMock.AssertWasCalled(
call => call.Save(
Arg<Website.CodeModules.BusinessObjects.Audit.ActivityLog>.Matches(
logItem => logItem.UserID == user.GuidID && logItem.Type == Enums.ActivityType.Login
)
)
);