【发布时间】:2011-07-13 15:01:51
【问题描述】:
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
PagingInfo 的 2 个类是 2 个实例,但具有相同的值,并且之前使用断言进行了验证。
这是单元测试代码
//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());
}
【问题讨论】:
-
请出示代码
标签: c# unit-testing rhino-mocks