This project has moved and is read-only. For the latest updates, please go here.

Test transaction rollback

Apr 22, 2016 at 6:26 PM
Hi,
I am using effort framework to test entity framework using Microsoft Unit testing framework. I am trying to test rolling back a transaction. The test code is

public void TestTransactionRollBack(){
  DbContext db = new DbContext();
  LoadData() // this method populates the tables in the memory database
  using (var trans = db.Database.BeginTransaction()){
      var result = db.MyTable.Find(1);
      result.DateChanged = null;
      db.SaveChanges();
      trans.RollBack();
  }     
  var result1 = db.MyTable.Find(1);
  Assert.IsNotNull(result1.DateChanged); //Assertion fails
}

Could you please suggest how to test if the changes were rolled back or not.

Thank you