Beispiel #1
0
        public void GivenSomeChildAddedWhenGettingSiblingRelationshipThenAllSiblingsShown()
        {
            var targetChild        = ChildName + 0;
            var numberOfChildToAdd = 3;

            for (int i = 0; i < numberOfChildToAdd; i++)
            {
                _familyTree.AddChild(FamilyTree.QueenName, ChildName + i, Gender.Female);
            }

            var result = _familyTree.GetRelationship(targetChild, Relationship.Siblings);

            Assert.AreEqual(string.Join(" ", result), $"{ChildName + 1} {ChildName + 2}");
        }
Beispiel #2
0
        private static void ProcessCommand(Command command, string[] parts)
        {
            string result;

            switch (command)
            {
            case Command.ADD_CHILD:
                string mother = parts[1];
                string child  = parts[2];
                Gender gender = GenderToEnum(parts[3]);
                result = familyTree.AddChild(mother, child, gender);
                Console.WriteLine(result);
                break;

            case Command.GET_RELATIONSHIP:
                string   person   = parts[1];
                Relation relation = RelationToEnum(parts[2]);
                result = familyTree.GetRelationship(person, relation);
                Console.WriteLine(result);
                break;
            }
        }