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); }
public void DistinctTypes() { 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 ); }
public ReferenceEstrato(ReferenceEstrato parentEstrato, Repository repository) { if (repository == null && parentEstrato == null) { throw new ArgumentNullException( "You must specify either a repository or a parent estrato " + "in order to create an estrato instance"); } this.EstratoType = EstratoType.Survey; this.ParentEstrato = parentEstrato; if (repository == null) { this.Container = parentEstrato.Repository; } else { this.Container = repository; } }
public ReferenceEstrato(Repository repository) : this(null, repository) { }