Fluent nhibernate Fluent NHibernate测试验证应用

Fluent nhibernate Fluent NHibernate测试验证应用,fluent-nhibernate,Fluent Nhibernate,鉴于以下情况 [Test] public void VerifyMappings() { new PersistenceSpecification<Address>(Session) .CheckProperty(x => x.AddressLine1, "190 House 12") .VerifyTheMappings(); } [测试] public void VerifyM

鉴于以下情况

    [Test]
    public void VerifyMappings()
    {
        new PersistenceSpecification<Address>(Session)
            .CheckProperty(x => x.AddressLine1, "190 House 12")
            .VerifyTheMappings();
    }
[测试]
public void VerifyMappings()
{
新PersistenceSpecification(会话)
.CheckProperty(x=>x.AddressLine1,“190号住宅12”)
.验证应用程序();
}

下面将尝试对datbase执行读写操作,但它会保留记录。是否可以使用fluent framework删除此记录?

只需在
[TearDown]
中使用类似的内容即可:

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

这将回滚当前事务。

只需在
[TearDown]
中使用类似的内容:

var currentSession = NHibernateSession.Current;
if (currentSession.Transaction.IsActive) {
    currentSession.Flush();
    currentSession.Transaction.Rollback();
}
这将回滚当前事务