public void TestGetRelationships() { MockTeam teamA = new(); MockTeam teamB = new(); MockTeam teamC = new(); var graph = new AllianceGraph(); graph.AddRelation(teamA, teamB, TeamRelationship.Allied); graph.AddRelation(teamA, teamC, TeamRelationship.Neutral); var relationships = graph.GetRelationships(teamA); foreach (var relationship in relationships) { if (relationship.Key == teamB) { Assert.AreEqual(TeamRelationship.Allied, relationship.Value); } if (relationship.Key == teamC) { Assert.AreEqual(TeamRelationship.Neutral, relationship.Value); } } }
/// <summary> /// Adds a relationship directed from team a to team b. /// </summary> /// <param name="teamA">The team where the relationship originates from.</param> /// <param name="teamB">The team that the relationship is directed to.</param> /// <param name="relationship">The relationship this team has.</param> /// <returns>The arena buildter to allow for chaining.</returns> public ArenaBuilder <T> AddTeamRelationship(T teamA, T teamB, TeamRelationship relationship) { if (!teams.Contains(teamA)) { throw new InvalidOperationException($"{teamA} has not been added to this arena."); } if (!teams.Contains(teamB)) { throw new InvalidOperationException($"{teamB} has not been added to this arena."); } allianceGraph.AddRelation(teamA, teamB, relationship); return(this); }