예제 #1
0
        public void ParentsTest()
        {
            //AddRelationship George and Mary as Bob's Parents
            FamilyGraph familyGraph = new FamilyGraph(PersonStore);

            familyGraph.AddRelationship("George", "Bob", "Parent");
            familyGraph.AddRelationship("Mary", "Bob", "Parent");
            IEnumerable <Person> actual   = familyGraph.Parents(bob);
            IEnumerable <Person> expected = PersonStore.GetPeople(new List <string>()
            {
                "George", "Mary"
            });

            actual.Should().BeEquivalentTo(expected);
        }
예제 #2
0
 private static void LoadRelationships()
 {
     using (var reader = new StreamReader(@"InputFiles\Relationships.txt"))
     {
         while (!reader.EndOfStream)
         {
             var line   = reader.ReadLine();
             var values = line.Split(',').Select(m => m.Trim()).ToList();
             FamilyGraph.AddRelationship(values[0], values[1], values[2]);
         }
     }
 }
예제 #3
0
        public void SiblingsHaveSameParentsTest()
        {
            //AddRelationship George and Mary as Bob's Parents
            FamilyGraph familyGraph = new FamilyGraph(PersonStore);

            familyGraph.AddRelationship("George", "Bob", "Parent");
            familyGraph.AddRelationship("Mary", "Bob", "Parent");
            familyGraph.AddRelationship("George", "Dave", "Parent");
            familyGraph.AddRelationship("Mary", "Dave", "Parent");
            familyGraph.AddRelationship("George", "Sally", "Parent");
            familyGraph.AddRelationship("Mary", "Sally", "Parent");
            familyGraph.Parents(dave).Should().BeEquivalentTo(familyGraph.Parents(bob));
        }
예제 #4
0
        public void ChildrenTest()
        {
            //AddRelationship George and Mary as Bob's Parents
            FamilyGraph familyGraph = new FamilyGraph(PersonStore);

            familyGraph.AddRelationship("George", "Bob", "Parent");
            familyGraph.AddRelationship("Mary", "Bob", "Parent");
            familyGraph.AddRelationship("George", "Dave", "Parent");
            familyGraph.AddRelationship("Mary", "Dave", "Parent");
            familyGraph.AddRelationship("George", "Sally", "Parent");
            familyGraph.AddRelationship("Mary", "Sally", "Parent");
            IEnumerable <Person> actual   = familyGraph.Children(george);
            IEnumerable <Person> expected = new List <Person>()
            {
                dave, bob, sally
            };

            actual.Should().BeEquivalentTo(expected);
        }
예제 #5
0
        public void SetUp()
        {
            IPersonStore PersonStore = new PersonStore();

            george                = PersonStore.AddPerson("George", Gender.Male);
            mary                  = PersonStore.AddPerson("Mary", Gender.Female);
            bob                   = PersonStore.AddPerson("Bob", Gender.Male);
            sally                 = PersonStore.AddPerson("Sally", Gender.Female);
            dave                  = PersonStore.AddPerson("Dave", Gender.Male);
            davesMaternalUncle    = PersonStore.AddPerson("Hulk", Gender.Male);
            davesPaternalAunt     = PersonStore.AddPerson("Aunt", Gender.Female);
            davesMaternalGrandDad = PersonStore.AddPerson("Thor", Gender.Male);
            davesMaternalGrandMom = PersonStore.AddPerson("Wonder", Gender.Female);
            davesPaternalGrandDad = PersonStore.AddPerson("Thor1", Gender.Male);
            davesPaternalGrandMom = PersonStore.AddPerson("Wonder1", Gender.Female);

            amy          = PersonStore.AddPerson("Amy", Gender.Female);
            bamy         = PersonStore.AddPerson("Bamy", Gender.Female);
            miller       = PersonStore.AddPerson("Miller", Gender.Male);
            amysBrother  = PersonStore.AddPerson("BigB", Gender.Male);
            amysBrother1 = PersonStore.AddPerson("ABig", Gender.Male);
            amysMom      = PersonStore.AddPerson("Miley", Gender.Female);
            amysDad      = PersonStore.AddPerson("Brad", Gender.Male);

            FamilyGraph familyGraph = new FamilyGraph(PersonStore);

            //Daves Family
            familyGraph.AddRelationship("Thor", "Mary", "Parent");
            familyGraph.AddRelationship("Wonder", "Mary", "Parent");
            familyGraph.AddRelationship("Thor", "Hulk", "Parent");
            familyGraph.AddRelationship("Wonder", "Hulk", "Parent");

            familyGraph.AddRelationship("Thor1", "George", "Parent");
            familyGraph.AddRelationship("Wonder1", "George", "Parent");
            familyGraph.AddRelationship("Thor1", "Aunt", "Parent");
            familyGraph.AddRelationship("Wonder1", "Aunt", "Parent");

            familyGraph.AddRelationship("George", "Bob", "Parent");
            familyGraph.AddRelationship("Mary", "Bob", "Parent");
            familyGraph.AddRelationship("George", "Dave", "Parent");
            familyGraph.AddRelationship("Mary", "Dave", "Parent");
            familyGraph.AddRelationship("George", "Sally", "Parent");
            familyGraph.AddRelationship("Mary", "Sally", "Parent");


            //Spouse
            familyGraph.AddRelationship("Dave", "Amy", "Spouse");

            //Amy's Family
            familyGraph.AddRelationship("Brad", "Miller", "Parent");
            familyGraph.AddRelationship("Miley", "Miller", "Parent");
            familyGraph.AddRelationship("Brad", "ABig", "Parent");
            familyGraph.AddRelationship("Miley", "ABig", "Parent");
            familyGraph.AddRelationship("Brad", "BigB", "Parent");
            familyGraph.AddRelationship("Miley", "BigB", "Parent");
            familyGraph.AddRelationship("Brad", "Amy", "Parent");
            familyGraph.AddRelationship("Miley", "Amy", "Parent");
            familyGraph.AddRelationship("Brad", "Bamy", "Parent");
            familyGraph.AddRelationship("Miley", "Bamy", "Parent");

            relationships = new Relationships(familyGraph);
        }