示例#1
0
        public void Init()
        {
            CResultAErreur result = CResultAErreur.True;

            CTimosTestMetierApp.AssureInit();
            m_contexteDonnee = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false);
            using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false))
            {
                CVersionDonnees version1 = null;
                for (int nVersion = 0; nVersion < m_nIdsVersions.Length; nVersion++)
                {
                    CVersionDonnees version = new CVersionDonnees(contexte);
                    if (version.ReadIfExists(new CFiltreData(CVersionDonnees.c_champLibelle + "=@1 and " +
                                                             CVersionDonnees.c_champTypeVersion + "=@2",
                                                             GetLibelleVersion(nVersion),
                                                             (int)CTypeVersion.TypeVersion.Previsionnelle)))
                    {
                        m_nIdsVersions[nVersion] = version.Id;
                    }
                    else
                    {
                        version.CreateNew();
                        version.Libelle         = GetLibelleVersion(nVersion);
                        version.CodeTypeVersion = (int)CTypeVersion.TypeVersion.Previsionnelle;
                        version.Date            = DateTime.Now;
                        if (nVersion == 2)
                        {
                            version.VersionParente = version1;
                        }
                        result = version.CommitEdit();
                        if (!result)
                        {
                            throw new CExceptionErreur(result.Erreur);
                        }
                        m_nIdsVersions[nVersion] = version.Id;
                    }
                    if (nVersion == 0)
                    {
                        version1 = version;
                    }
                }
            }
            //Création de l'acteur de test
            CActeur acteur = new CActeur(m_contexteDonnee);

            if (!acteur.ReadIfExists(new CFiltreData(CActeur.c_champPrenom + "=@1",
                                                     "NUNIT ACTEUR")))
            {
                acteur.CreateNew();
                acteur.Nom    = "NUnit acteur";
                acteur.Prenom = "NUNIT ACTEUR";
                result        = acteur.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdActeur = acteur.Id;


            //Remet le jeu de test à 0
            ResetModifs();
        }
        public void SetUptTest()
        {
            CResultAErreur result = CResultAErreur.True;

            CTimosTestMetierApp.AssureInit();
            m_contexteDonnee = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false);

            //Création de l'acteur de test
            CActeur acteur = new CActeur(m_contexteDonnee);

            if (!acteur.ReadIfExists(new CFiltreData(CActeur.c_champNom + "=@1",
                                                     c_strNomActeur)))
            {
                acteur.CreateNew();
                acteur.Nom    = c_strNomActeur;
                acteur.Prenom = "Youcef";
                result        = acteur.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdActeur = acteur.Id;

            // Création des Types d'occupation horraire
            // Repos
            CTypeOccupationHoraire toRepos = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toRepos.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strRepos)))
            {
                toRepos.CreateNew();
                toRepos.Libelle  = c_strRepos;
                toRepos.Priorite = 10;
                result           = toRepos.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationRepos = toRepos.Id;
            // Jour
            CTypeOccupationHoraire toJour = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toJour.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strJour)))
            {
                toJour.CreateNew();
                toJour.Libelle  = c_strJour;
                toJour.Priorite = 50;
                result          = toJour.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationJour = toJour.Id;
            // Astreinte
            CTypeOccupationHoraire toAstreinte = new CTypeOccupationHoraire(m_contexteDonnee);

            if (!toAstreinte.ReadIfExists(
                    new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strAstreinte)))
            {
                toAstreinte.CreateNew();
                toAstreinte.Libelle  = c_strAstreinte;
                toAstreinte.Priorite = 100;
                result = toAstreinte.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdOccupationAstreinte = toAstreinte.Id;

            // Création de l'Horaire journalier
            CHoraireJournalier horaire = new CHoraireJournalier(m_contexteDonnee);

            if (!horaire.ReadIfExists(
                    new CFiltreData(CHoraireJournalier.c_champLibelle + "=@1", c_strLabelHoraireJournalier)))
            {
                horaire.CreateNew();
                horaire.Libelle = c_strLabelHoraireJournalier;
                result          = horaire.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdHoraireJournalier = horaire.Id;

            // Création du Calendier
            CCalendrier calendrier = new CCalendrier(m_contexteDonnee);

            if (!calendrier.ReadIfExists(
                    new CFiltreData(CCalendrier.c_champLibelle + "=@1", c_strLabelCalendrier)))
            {
                calendrier.CreateNew();
                calendrier.Libelle          = c_strLabelCalendrier;
                calendrier.Acteur           = acteur;
                calendrier.HoraireParDefaut = horaire;
                result = calendrier.CommitEdit();
                Assert.IsTrue(result.Result);
            }
            m_nIdCalendrier = calendrier.Id;

            // CRéation de l'EO de test
            CTypeEntiteOrganisationnelle tpEO = new CTypeEntiteOrganisationnelle(m_contexteDonnee);

            if (!tpEO.ReadIfExists(
                    new CFiltreData(CTypeEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelTypeEO)))
            {
                tpEO.CreateNew();
                tpEO.Libelle = c_strLabelTypeEO;
                Assert.IsTrue(tpEO.CommitEdit());
            }
            m_nIdTypeEO = tpEO.Id;

            CEntiteOrganisationnelle eo = new CEntiteOrganisationnelle(m_contexteDonnee);

            if (!eo.ReadIfExists(
                    new CFiltreData(CEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelEO)))
            {
                eo.CreateNew();
                eo.Libelle    = c_strLabelEO;
                eo.TypeEntite = tpEO;
                Assert.IsTrue(eo.CommitEdit());
            }
            m_nIdEO = eo.Id;

            // Affecte l'EO à l'acteur de test
            acteur.AjouterEO(m_nIdEO);
        }