我正在我的项目中编写DAO单元测试,使用
单元测试代码如下:
ObjectSet
类时遇到问题。我必须创建一个新的ObjectSet
,但是为了做到这一点,我不能连接到数据库。因此,我无法使用BusinessModelContainer
的CreateObjectSet()
方法。有没有办法在没有连接的情况下创建ObjectSet
?单元测试代码如下:
var mock = new Mock<IBusinessModelContainerWrapper>();
ObjectSet<Student> expectedStudent = ???; // how can I get an instance here?
StudentDao studentDao = new StudentDao(mock.Object);
expectedStudent.Add(someObj);
mock.Setup(c => c.Students).Returns(expectedStudent);
Assert.AreEqual(someObj, studentDao.GetByQuery(...));