Rhino.Mocks.Exceptions.ExpectationViolationException was unhandled by user code
Message=Service.GetCommunityLightPagered(null, 1, null, null, Data.PagingInfo);
Expected #0, Actual #1.
Service.GetCommunityLightPagered(null, 1, null, null, Data.PagingInfo);
Expected #1, Actual #0.
Source=Rhino.Mocks
The 2 classes PagingInfo are 2 instances but have the same values and are verified before with asserts.
Here is the unit test code
//Arrange
GetController("user1");
//Act
using (MockRepository.Record())
{
Expect.Call(
ServiceClient.GetMock<Service>().GetUserPermissionSet(
"user1", false, false, false)).Return(
Db.User.Permissions.Where(p => p.Name == "CreateCommunity").ToArray());
}
using (MockRepository.Playback())
{
ActionResult result = Controller.ExecuteAction<int?, int?, string, string, string, string, string, string>(ServiceClient, Controller.SearchCommunities, null, null,null, null, null, CommunityTypeEnum.HighSchool, null,null);
//Assert
Assert.AreEqual(typeof(PartialViewResult), result.GetType());
}
problem solved :
Now all calls to this ,will be considered valid.
Edit 1: Why you should use IgnoreArguments()? Because sometimes you have big objects that need to be mocked and maybe you only want to test a small part of it.
I usually use it when i have objects as parameters.
Another way to avoid using it is by using same hashcode to both objects, the one used for record and the one used as param in playback.