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