예제 #1
0
        static void Main(string[] args)
        {
            personStore = new PersonStore();
            LoadPeople();

            FamilyGraph = new FamilyGraph(personStore);
            LoadRelationships();

            FamilyRelationships = new Relationships(FamilyGraph);
            using (var reader = new StreamReader(@"InputFiles\Testcase.txt"))
            {
                while (!reader.EndOfStream)
                {
                    var input  = reader.ReadLine();
                    var values = input.Split(" ").Select(m => m.Trim()).ToList();
                    Console.WriteLine($"TestCase: {input}");
                    if (values[0] == "ADD_CHILD")
                    {
                        AddChild(values);
                    }
                    else if (values[0] == "GET_RELATIONSHIP")
                    {
                        try
                        {
                            GetRelationship(values);
                        }
                        catch (Exception) { }
                    }
                    Console.WriteLine();
                }
            }
            Console.ReadKey();
        }
예제 #2
0
파일: 主窗口.cs 프로젝트: victorlw1/UI
 public 主窗口()
 {
     InitializeComponent();
     myFamilyTree  = new FamilyTree();
     myFamilyGraph = new FamilyGraph();
     //压力测试
     //pressureTest();
 }
예제 #3
0
        public void EmptyParentsTest()
        {
            //AddRelationship George and Mary as Bob's Parents
            FamilyGraph          familyGraph = new FamilyGraph(PersonStore);
            IEnumerable <Person> actual      = familyGraph.Parents(bob);
            IEnumerable <Person> expected    = new List <Person>();

            actual.Should().BeEquivalentTo(expected);
        }
예제 #4
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));
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }