public void AssertPaternalUncleOfKriyaisSaayan() { Ape kriya = _apeService.GetElement("Kriya"); Ape saayan = _apeService.GetElement("Saayan"); Ape asva = _apeService.GetElement("Asva"); List <Ape> parent = kriya.GetParent(GenderType.Male, _apeFamilyAssociationService); Assert.That(new List <Ape>() { saayan, asva }, Is.EqualTo(kriya.GetUncleOrAuntOnMaternalOrPaternalSide(GenderType.Male, _apeFamilyAssociationService, parent.ElementAt(0)))); Assert.That(RelationshipType.PaternalUncle, Is.EqualTo(_apeFamilyAssociationService.GetRelationshipBetweenApes(kriya, saayan))); }
static void Main(string[] args) { ApeService apeService = new ApeService(); ApeFamilyService apeFamilyService = new ApeFamilyService(apeService); ApeFamilyAssociationService apeFamilyAssociationService = new ApeFamilyAssociationService(apeFamilyService); int userInput = 0; do { userInput = DisplayMenu(apeService); switch (userInput) { case 1: try { Console.WriteLine("Please enter the name of the Ape you want to find relationship for:"); string apeName = Console.ReadLine(); Console.WriteLine("Enter RelationShip Type"); string relationShipType = Console.ReadLine(); Ape ape = apeService.GetElement(apeName); Models.RelationshipType relationship; if (!Enum.TryParse(relationShipType, true, out relationship)) { throw new Exception("Invalid Relationship"); } List <Ape> apes = ape.CalculateRelationship(relationship, apeFamilyAssociationService, apeFamilyService); Utility.PrintName(apes); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("We should start from all over"); } break; case 2: try { Console.WriteLine("Please enter the name of the parent you want add the family under"); string parent = Console.ReadLine(); Console.WriteLine("Enter child name:"); string child = Console.ReadLine(); Console.WriteLine("Enter child gender:"); string genderType = Console.ReadLine(); Ape parentApe = apeService.GetElement(parent); Models.GenderType gender; if (!Enum.TryParse(genderType, true, out gender)) { throw new Exception("We are not aware of such a gender!!"); } ApeFamily apeFamily = apeFamilyService.GetAll().SingleOrDefault(p => p.Partners.Contains(parentApe)); if (apeFamily == null) { throw new Exception("That would be incorrect. Apes are not Godzillas."); } Ape newBorn = apeFamily.AddNewBorn(child, parentApe.GetDepthLevel() + 1, gender); apeFamilyAssociationService.AddElement(child, apeFamily); apeService.AddElement(newBorn.GetName(), newBorn); Console.WriteLine($"New born {newBorn.GetName()} successfully added to family"); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("We should start from all over"); } break; case 3: Utility.PrintName(apeFamilyService.GetMothersWithMaximumGirlApes()); break; case 4: try { Console.WriteLine("Please enter the name of the ape1"); string ape1Name = Console.ReadLine(); Console.WriteLine("Please enter the name of the ape1"); string ape2Name = Console.ReadLine(); Ape ape1 = apeService.GetElement(ape1Name); Ape ape2 = apeService.GetElement(ape2Name); Utility.PrintName(apeFamilyAssociationService.GetRelationshipBetweenApes(ape1, ape2)); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("We should start from all over"); } break; } } while (userInput != 5); Console.WriteLine(); }