예제 #1
0
        public void DaughterTest1()
        {
            var GeorgeSons = relationships.Daughter("George");
            var expected   = new List <Person>()
            {
                sally
            };

            GeorgeSons.Should().BeEquivalentTo(expected, m => m.WithStrictOrdering());
        }
예제 #2
0
        private static void GetRelationship(List <string> values)
        {
            IEnumerable <Person> result = new List <Person>();

            switch (values[2])
            {
            case "Paternal-Uncle":
                try
                {
                    result = FamilyRelationships.PaternalUncle(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Maternal-Uncle":
                try
                {
                    result = FamilyRelationships.MaternalUncle(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Paternal-Aunt":
                try
                {
                    result = FamilyRelationships.PaternalAunt(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Maternal-Aunt":
                try
                {
                    result = FamilyRelationships.MaternalAunt(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Brother-In-Law":
                try
                {
                    result = FamilyRelationships.BrotherInLaw(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Sister-In-Law":
                try
                {
                    result = FamilyRelationships.SisterInLaw(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Son":
                try
                {
                    result = FamilyRelationships.Son(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Daughter":
                try
                {
                    result = FamilyRelationships.Daughter(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;

            case "Siblings":
                try
                {
                    result = FamilyRelationships.Siblings(values[1]);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("Output : PERSON_NOT_FOUND");
                    throw;
                }
                break;
            }
            var    names         = result.Select(m => m.Name);
            string namesAsString = names.Count() == 0 ? "NONE"  : string.Join(" ", names);

            Console.WriteLine($"Output : {namesAsString}");
        }