public void AbortedDeferredMultiStepTransactionDoesNotCommit() { PersistenceManager pm = new PersistenceManager(); var landCount = LänderCount(pm); var fhCount = FlughafenCount(pm); pm.LogAdapter = new TestLogAdapter(); pm.VerboseMode = true; pm.TransactionMode = TransactionMode.Optimistic; Land land = new Land(); land.Name = "Germany"; pm.MakePersistent(land); pm.Save(true); var flughafen = new Flughafen(); flughafen.Kürzel = "MUC"; pm.MakePersistent(flughafen); land.AddFlughafen(flughafen); pm.Save(true); pm.Abort(); string log = pm.LogAdapter.ToString(); //Assert.That( new Regex( "Creating a new TransactionScope" ).Matches( log ).Count == 1, "One Transactions should be started" ); //Assert.That( log.IndexOf( "Completing" ) == -1, "Transaction should be committed" ); //Assert.That( new Regex( "Rollback transaction" ).Matches( log ).Count == 1, "One Transactions should be rolled back" ); pm.TransactionMode = TransactionMode.None; Assert.AreEqual(landCount, LänderCount(pm)); Assert.AreEqual(fhCount, FlughafenCount(pm)); }
public void TestAddFlughafen() { pm.MakePersistent(l); pm.MakePersistent(f); l.AddFlughafen(f); pm.Save(); pm.UnloadCache(); IQuery q = new NDOQuery <Land>(pm, null); l = (Land)q.ExecuteSingle(true); Assert.NotNull(l, "Land not found"); Assert.AreEqual(1, l.Flughäfen.Count, "Count wrong"); Flughafen f2 = CreateFlughafen("FRA"); pm.MakePersistent(f2); l.AddFlughafen(f2); pm.VerboseMode = true; pm.Save(); pm.VerboseMode = false; pm.UnloadCache(); l = (Land)q.ExecuteSingle(true); Assert.AreEqual(2, l.Flughäfen.Count, "Count wrong"); }
public void TestCreateObjectsSave() { pm.MakePersistent(l); pm.MakePersistent(f); l.AddFlughafen(f); pm.Save(); Assert.That(!l.NDOObjectId.Equals(f.NDOObjectId), "Ids should be different"); l = (Land)pm.FindObject(l.NDOObjectId); f = (Flughafen)pm.FindObject(f.NDOObjectId); Assert.NotNull(l, "1. Land not found"); Assert.NotNull(f, "1. Flughafen not found"); pm.UnloadCache(); l = (Land)pm.FindObject(l.NDOObjectId); f = (Flughafen)pm.FindObject(f.NDOObjectId); Assert.NotNull(l, "2. Land not found"); Assert.NotNull(f, "2. Flughafen not found"); }