Database fixture problem

6 posts, 0 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 10 Nov 2008 Link to this post

    When i was using NHibernate and Linq to SQL I've created database fixture, which rollbacks database changes 
    after each test.

        public class DatabaseFixture : IDisposable
        {
            private readonly TransactionScope transactionScope;

            protected DatabaseFixture()
            {
                transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
            }

            #region IDisposable Members

            public void Dispose()
            {
                transactionScope.Dispose();
            }

            #endregion
        }
    But now it doesn't rollbacks changes made on object scope transaction commit. Any ideas how to get it work =)


  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 10 Nov 2008 Link to this post

    Hi Alexey,

    You should not use the scope.Transaction, you have to change the transaction properties of your database so that we integrate us into system.transactions:

    database.Properties.TransactionProvider = TransactionProvider.TransactionScope;

    Greetings,
    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 10 Nov 2008 Link to this post

    But if want to use scope transaction. How can i implement such database fixture (It should rollback any changes within database made during the test)?


  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 10 Nov 2008 Link to this post

    Hi Alexey,

    You can only do it in the same way. just set the property at Database and use your code as it is.

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 10 Nov 2008 Link to this post

    Also Open Access Transaction has Level property which determinate nesting level. But I don't understand how we can create nested transactions? There is nothing said about it in documentation.
  7. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 11 Nov 2008 Link to this post

    Hello Alexey,

    Nested transactions are not supported at the moment. The level can only be 0 and 1.

    Best wishes,
    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
DevCraft banner