Ejemplo n.º 1
0
        public void CompTestHollow()
        {
            var pm = PmFactory.NewPersistenceManager();

            m.SVN = svn;
            pm.MakePersistent(m);
            pm.Save();
            pm.MakeHollow(m);               // setzt m.svn auf null

            Assert.AreEqual(NDOObjectState.Hollow, m.NDOObjectState, "1: Mitarbeiter should be hollow");
            Assert.AreEqual(NDOObjectState.Persistent, svn.NDOObjectState, "1: SVN should be persistent");

            svn = m.SVN;             // ruft LoadData för m auf. m.svm liegt auf dem Cache und ist Persistent
            Assert.AreEqual(NDOObjectState.Persistent, m.NDOObjectState, "1: Mitarbeiter should be persistent");
            Assert.AreEqual(NDOObjectState.Persistent, svn.NDOObjectState, "2: SVN should be persistent");
            ObjectId id = m.NDOObjectId;

            pm.Close();
            pm = PmFactory.NewPersistenceManager();
            m  = (Mitarbeiter)pm.FindObject(id);
            Assert.NotNull(m, "Mitarbeiter not found");
            Assert.AreEqual(NDOObjectState.Hollow, m.NDOObjectState, "2: Mitarbeiter should be hollow");
            svn = m.SVN;
            Assert.AreEqual(NDOObjectState.Persistent, m.NDOObjectState, "2: Mitarbeiter should be persistent");
            Assert.NotNull(svn, "SVN not found");
            Assert.AreEqual(NDOObjectState.Hollow, svn.NDOObjectState, "1: SVN should be hollow");
            Assert.AreSame(m, svn.Angestellter, "2. Backlink wrong");
        }
Ejemplo n.º 2
0
        public void CompTestCreateObjectsSave()
        {
            var pm = PmFactory.NewPersistenceManager();

            m.SVN = svn;
            pm.MakePersistent(m);
            pm.Save();
            Assert.That(!m.NDOObjectId.Equals(m.SVN.NDOObjectId), "Ids should be different");
            m   = (Mitarbeiter)pm.FindObject(m.NDOObjectId);
            svn = (Sozialversicherungsnummer)pm.FindObject(m.SVN.NDOObjectId);
            Assert.NotNull(m, "1. Mitarbeiter not found");
            Assert.NotNull(svn, "1. SVN not found");
            ObjectId moid = m.NDOObjectId;
            ObjectId soid = svn.NDOObjectId;

            m   = null;
            svn = null;

            pm.UnloadCache();
            m = (Mitarbeiter)pm.FindObject(moid);
            Sozialversicherungsnummer s2 = m.SVN;

            svn = (Sozialversicherungsnummer)pm.FindObject(soid);
            Assert.NotNull(m, "2. Mitarbeiter not found");
            Assert.NotNull(svn, "2. SVN not found");
            Assert.AreSame(svn, s2, "SVN should match");
            Assert.AreSame(m, svn.Angestellter, "Mitarbeiter should match");
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     count++;
     m       = CreateMitarbeiter("Boris", "Becker");
     svn     = new Sozialversicherungsnummer();
     svn.SVN = 4711;
     e       = new Email("*****@*****.**");
     z0      = new Zertifikat();
     z0.Key  = 42;            // :-)
 }
Ejemplo n.º 4
0
        public void CompTestAddObjectSave()
        {
            var pm = PmFactory.NewPersistenceManager();

            pm.MakePersistent(m);
            pm.Save();
            m.SVN = svn;
            Assert.AreEqual(NDOObjectState.Created, svn.NDOObjectState, "1. Wrong state");
            Assert.AreSame(m, svn.Angestellter, "1. Backlink wrong");
            pm.Save();
            m   = (Mitarbeiter)pm.FindObject(m.NDOObjectId);
            svn = (Sozialversicherungsnummer)pm.FindObject(svn.NDOObjectId);
            Assert.NotNull(m, "1. Mitarbeiter not found");
            Assert.NotNull(svn, "1. SVN not found");
            Assert.AreEqual(NDOObjectState.Persistent, svn.NDOObjectState, "2. Wrong state");
            Assert.AreSame(m, svn.Angestellter, "2. Backlink wrong");
        }
Ejemplo n.º 5
0
        public void Setup()
        {
            pm      = PmFactory.NewPersistenceManager();
            m       = CreateMitarbeiter("Boris", "Becker");
            svn     = new Sozialversicherungsnummer();
            svn.SVN = 4711;
            m.SVN   = svn;
            pm.MakePersistent(m);
            ass = pm.GetType().Assembly;
            r   = pm.NDOMapping.FindClass(typeof(Mitarbeiter)).FindRelation("sn");
            fr  = r.ForeignRelation;
            t   = ass.GetType("NDO.ObjectLock", true);
            if (t != null)
            {
                theLock = Activator.CreateInstance(t);
            }

            //			pm.Save();
        }
Ejemplo n.º 6
0
        public void CompTestReplaceChildAbort()
        {
            var pm = PmFactory.NewPersistenceManager();

            pm.MakePersistent(m);
            m.SVN = svn;
            Assert.AreSame(svn.Angestellter, m, "1. Mitarbeiter should be same");
            pm.Save();
            Assert.NotNull(m.SVN, "1. SVN not found");
            Sozialversicherungsnummer svn2 = new Sozialversicherungsnummer();

            svn2.SVN = 0815;
            m.SVN    = svn2;
            pm.Abort();
            Assert.AreEqual(NDOObjectState.Transient, svn2.NDOObjectState, "1. Wrong state");
            Assert.AreEqual(NDOObjectState.Persistent, svn.NDOObjectState, "2. Wrong state");
            Assert.Null(svn2.Angestellter, "3. No relation to Mitarbeiter");
            Assert.AreSame(svn.Angestellter, m, "4. Mitarbeiter should be same");
            Assert.AreSame(m.SVN, svn, "5. SVN should be same");
        }