Exemple #1
0
        public void Creation()
        {
            Repository repos = new Repository();

            repos.Save();

            ReferenceEstrato refEst = new ReferenceEstrato();

            refEst.Repository = repos;

            ReferenceEstrato subRefEst1 = new ReferenceEstrato();

            subRefEst1.ParentEstrato = refEst;
            subRefEst1.Repository    = repos;
            ReferenceEstrato subRefEst2 = new ReferenceEstrato();

            subRefEst2.ParentEstrato = refEst;
            subRefEst2.Repository    = repos;

            refEst.Save();
            subRefEst1.Save();
            subRefEst2.Save();

            ReferenceEstrato[] refEsts = ReferenceEstrato.FindAll();
            Assert.AreEqual(3, refEsts.Length);

            SurveyEstrato[] surEsts = SurveyEstrato.FindAll();
            Assert.AreEqual(0, surEsts.Length);
        }
Exemple #2
0
        public void UsageWithReferences()
        {
            Repository repos = new Repository();

            ReferenceEstrato loc      = new ReferenceEstrato(repos);
            ReferenceEstrato sul      = new ReferenceEstrato(loc);
            ReferenceEstrato norte    = new ReferenceEstrato(loc);
            ReferenceEstrato sudeste  = new ReferenceEstrato(loc);
            ReferenceEstrato nordeste = new ReferenceEstrato(loc);

            using (new SessionScope())
            {
                repos.Save();
                loc.Save();
                sul.Save();
                sudeste.Save();
                norte.Save();
                nordeste.Save();
            }

            Survey pesquisa = new Survey();

            SurveyEstrato extCidade = new SurveyEstrato(pesquisa);

            extCidade.ReferencedEstratos.Add(loc);

            SurveyEstrato extSub1 = new SurveyEstrato(extCidade, pesquisa);

            extSub1.ReferencedEstratos.Add(sudeste);

            SurveyEstrato extSub2 = new SurveyEstrato(extCidade, pesquisa);

            extSub2.ReferencedEstratos.Add(sudeste);

            SurveyEstrato extSub3 = new SurveyEstrato(extCidade, pesquisa);

            extSub3.ReferencedEstratos.Add(sudeste);

            using (new SessionScope())
            {
                pesquisa.Save();
                extCidade.Save();
                extSub1.Save();
                extSub2.Save();
                extSub3.Save();
            }

            extCidade = SurveyEstrato.Find(extCidade.Id);
            Assert.IsNotNull(extCidade);

            Estrato[] estratos = SurveyEstrato.FindAll();
            Assert.AreEqual(4, estratos.Length);

            estratos = ReferenceEstrato.FindAll();
            Assert.AreEqual(5, estratos.Length);
        }