public void Setup() { var pm = PmFactory.NewPersistenceManager(); m = CreateMitarbeiter("Mirko", "Matytschak"); pm.MakePersistent(m); m.ErzeugeReise().Zweck = "ADC"; pm.Save(); pm.UnloadCache(); }
public void ChangeSetDetectsObjectAddition1_to_n() { var pm = PmFactory.NewPersistenceManager(); m = pm.Objects <Mitarbeiter>().Single(); var r = m.ErzeugeReise(); r.Zweck = "Test"; var changeObject = pm.GetChangeSet(m); var original = changeObject.original; var current = changeObject.current; Assert.AreEqual(1, original.Count); Assert.AreEqual(1, current.Count); Assert.That(original.ContainsKey("dieReisen")); Assert.That(current.ContainsKey("dieReisen")); Assert.AreEqual(1, ((List <ObjectId>)original["dieReisen"]).Count); Assert.AreEqual(2, ((List <ObjectId>)current["dieReisen"]).Count); Assert.AreEqual(r.NDOObjectId, ((List <ObjectId>)current["dieReisen"])[1]); // At this point it doesn't make any sense to serialize the changeObject, // since the id of r is not yet determined. Assert.That((int)r.NDOObjectId.Id[0] < 0); pm.Save(); // Now the id of r is determined. Let's assert, that the list in current reflects the change. Assert.That((int)r.NDOObjectId.Id[0] > 0); Assert.AreEqual(r.NDOObjectId, ((List <ObjectId>)current["dieReisen"])[1]); changeObject = changeObject.SerializableClone(); original = changeObject.original; current = changeObject.current; Assert.AreEqual(1, original.Count); Assert.AreEqual(1, current.Count); Assert.That(original.ContainsKey("dieReisen")); Assert.That(current.ContainsKey("dieReisen")); Assert.AreEqual(1, ((List <string>)original["dieReisen"]).Count); Assert.AreEqual(2, ((List <string>)current["dieReisen"]).Count); Assert.AreEqual(r.NDOObjectId.ToShortId(), ((List <string>)current["dieReisen"])[1]); string json = JsonConvert.SerializeObject(changeObject); }