Example #1
0
 public Relationship Add(Person person)
 {
     person.Family = this;
     var relationship = new Relationship { A = person };
     _relationships.Add(relationship);
     return relationship;
 }
 private void InitializePeople()
 {
     john = kennedy.Add("John");
     joe = kennedy.Add("Joe");
     rosemary = kennedy.Add("Rosemary");
     jackie = kennedy.Add("Jackie");
     jackiesSecondHusband = kennedy.Add("JackiesSecondHusband");
     kathleen = kennedy.Add("Kathleen");
     eunice = kennedy.Add("Eunice");
     pat = kennedy.Add("Pat");
     robert = kennedy.Add("Robert");
     jean = kennedy.Add("Jean");
     ted = kennedy.Add("Ted");
     miscarriage = kennedy.Add("miscarriage");
     daughter1 = kennedy.Add("daughter1");
     daughter2 = kennedy.Add("daughter2");
     son1 = kennedy.Add("son1");
     son2 = kennedy.Add("son2");
     kathleensHusband = kennedy.Add("KathleensHusband");
     kathleensSecondHusband = kennedy.Add("KathleensSecondHusband");
     ethyl = kennedy.Add("Ethyl");
     rdaughter1 = kennedy.Add("rdaughter1");
     rson1 = kennedy.Add("rson1");
     rson2 = kennedy.Add("rson2");
     rson3 = kennedy.Add("rson3");
     rdaughter2 = kennedy.Add("rdaughter2");
     rson4 = kennedy.Add("rson4");
     rdaugher3 = kennedy.Add("rdaugher3");
     rson5 = kennedy.Add("rson5");
     rson6 = kennedy.Add("rson6");
     rson7 = kennedy.Add("rson7");
     rdaugher4 = kennedy.Add("rdaugher4");
     joseph = kennedy.Add("Joseph");
     rose = kennedy.Add("Rose");
     gloria = kennedy.Add("Gloria");
     patrick = kennedy.Add("Patrick");
     patricksWife = kennedy.Add("PatricksWife");
     pdaughter1 = kennedy.Add("pdaughter1");
     pdaughter2 = kennedy.Add("pdaughter2");
     fitz = kennedy.Add("Fitz");
     mary = kennedy.Add("Mary");
     toodles = kennedy.Add("Toodles");
     fdaughter2 = kennedy.Add("fdaughter2");
     fson1 = kennedy.Add("fson1");
     fson2 = kennedy.Add("fson2");
     fdaughter3 = kennedy.Add("fdaughter3");
     fson3 = kennedy.Add("fson3");
     people = new List<Person> { john, joe, rosemary, jackie, jackiesSecondHusband, kathleen, eunice, pat, robert, jean, ted, miscarriage, daughter1, daughter2,
                                 son1, son2, kathleensHusband, kathleensSecondHusband, ethyl, rdaughter1, rson1, rson2, rson3, rdaughter2, rson4, rdaugher3, rson5, rson6, rson7, rdaugher4,
                                 joseph, rose, gloria, patrick, patricksWife, pdaughter1, pdaughter2, fitz, mary, toodles, fdaughter2, fson1, fson2, fdaughter3, fson3 };
 }
 public FamilyExtensionsTests()
 {
     _us = new Family();  _dad = _us.Add();  _mom = _us.Add();  _brother = _us.Add();  _sister = _us.Add();  _cat = _us.Add();
      _expectedChildren = new List<Person> { _brother, _sister, _cat };
 }
Example #4
0
 public IEnumerable<Person> SiblingsOf(Person person)
 {
     var parents = ParentsOf(person);
     return ChildrenOf(parents).Where(s => s != person);
 }
Example #5
0
 public IEnumerable<Person> ParentsOf(Person person)
 {
     return _relationships.Where(r => r.B == person && r.Type == RelationshipType.Parent).Select(r => r.A);
 }
Example #6
0
 public IEnumerable<Person> ChildrenOf(Person parent)
 {
     return _relationships.Where(r => r.Type == RelationshipType.Parent && r.A == parent).Select(r => r.B);
 }