我如何在.net中的nhibernate中的相同repository.SaveOrUpdate(Object)上设置期望。
答案 0 :(得分:0)
如果您使用Moq框架,则可以执行类似于...
Mock<IDataAccessObject> mockDataAccess = new Mock<IDataAccessObject>();
// Setting up the mock to return expected values as part of the tests
mockDataAccess.Setup(dal => dal.SaveOrUpdate(Object)).Returns(expectedReturnValue);
// Calling the receiver business layer passing in the mocked DataAccess
using (BusinessLayerObject bl = new BusinessLayerObject(mockDataAccess.Object))
{
result = bl.SaveOrUpdate(Object);
}