none
Using Com+ For Transaction in C# 2005 RRS feed

  • Question

  • Hi

    I have a problem when I tried to use COM+ to rollback data access method in unit test. Here is my code:

        [TestFixture]
        [Transaction(TransactionOption.Required)]
        public class DALImplTest
        {

           .....


            [Test]
            public void TestSaveEntity()
            {
                DALImpl dal = new DALImpl();
                dal.SaveEntity(_ds);

                DataSet ds = dal.GetEntity();
            }


            [TearDown]
            public void Rollback()
            {
                if (ContextUtil.IsInTransaction)
                {
                    ContextUtil.SetAbort();
                }
            }

        }

    I generated .snk file, but when I added [assembly: AssemblyKeyFile(...)] to AssemblyInfo.cs, system notified me to configure in project setting instead of using "AssemblyKeyFile". I think it's maybe the change of .Net 2005, and I do the setting.

    Complie is ok, but when the unit test is running, ContextUtil.SetAbort() hasn't been executed, and test data is inserted into database.

    Anyone can help.

     

    Thanks


    Tuesday, August 7, 2007 3:06 PM