Ok, I know nhibernate supports ambient transactions, because nhibernate sessions enlists in the ambient transactions while inside a transaction scope. However, there are some oddities, consider the following test:
[Test]
public void Transaction_RollsBackTransactionInsideOfAmbientTransaction_AmbientTransactionAborted()
{
// arrange
ISessionFactory sessionFactory = SessionFactoryOneTimeInitializer.GetTestSessionFactory();
ISession session = sessionFactory.OpenSession();
SessionFactoryOneTimeInitializer.CreateDataBaseSchemaIfRequiredByConfiguration(session);
using (new TransactionScope())
{
using (ITransaction transaction = session.BeginTransaction())
{
// act
transaction.Rollback();
}
// assert
Assert.AreEqual(TransactionStatus.Aborted, Transaction.Current.TransactionInformation.Status);
}
}
This test fails. How will nhibernate ensure that the ambient transaction is not persisted to the database?