2010-09-14 81 views
0

鑑於以下功能NHibernate測試VerifyTheMappings

[Test] 
    public void VerifyMappings() 
    { 
     new PersistenceSpecification<Address>(Session) 
      .CheckProperty(x => x.AddressLine1, "190 House 12") 
      .VerifyTheMappings(); 
    } 

下面將試圖做一個讀取和寫入datbase,但它留下的記錄。是否有可能使用流利的框架刪除此記錄?

回答

3

只要使用這樣的事情在你的[TearDown]

var currentSession = NHibernateSession.Current; 
if (currentSession.Transaction.IsActive) { 
    currentSession.Flush(); 
    currentSession.Transaction.Rollback(); 
} 

這將回滾當前事務。