[TestFixture]
public class CustomerTest
{
[Test]
public void Add()
{
CustomerService service = new CustomerService();
Customer entity = new Customer();
entity.LastName = "星星";
entity.FirstName = "周";
service.Add(entity);
}
}
跟踪后是service类下面的方法引起报错 (nhibernateSession.Get()返回的是null)
ISession session = nhibernateSession.Get();
if (session == null)
{
session = SessionFactory.OpenSession();
nhibernateSession.Set(session);
}
return session;
请问这个测试代码应怎么写才不会出现这个问题