public void GetTeamByTeamIdAndGetAssociatedWorkers() { var workerOne = SaveWorkerToDatabase( DatabaseGatewayHelper.CreateWorkerDatabaseEntity(1, "*****@*****.**")); var workerTwo = SaveWorkerToDatabase( DatabaseGatewayHelper.CreateWorkerDatabaseEntity(2, "*****@*****.**")); var workerTeamOne = SaveWorkerTeamToDatabase( DatabaseGatewayHelper.CreateWorkerTeamDatabaseEntity(id: 1, workerId: workerOne.Id, worker: workerOne)); var workerTeamTwo = SaveWorkerTeamToDatabase( DatabaseGatewayHelper.CreateWorkerTeamDatabaseEntity(id: 2, workerId: workerTwo.Id, worker: workerTwo)); var workerTeams = new List <WorkerTeam> { workerTeamOne, workerTeamTwo }; var team = SaveTeamToDatabase(DatabaseGatewayHelper.CreateTeamDatabaseEntity(workerTeams)); var responseTeam = _teamGateway.GetTeamByTeamId(team.Id); responseTeam?.WorkerTeams.Count.Should().Be(2); var responseWorkerTeams = responseTeam?.WorkerTeams.ToList(); var workerOneResponse = responseWorkerTeams?.Find(workerTeam => workerTeam.Worker.Id == workerOne.Id)?.Worker; var workerTwoResponse = responseWorkerTeams?.Find(workerTeam => workerTeam.Worker.Id == workerTwo.Id)?.Worker; workerOneResponse.Should().BeEquivalentTo(workerOne); workerTwoResponse.Should().BeEquivalentTo(workerTwo); }
public void GetTeamByTeamIdReturnsTeamWithWorkers() { var team = SaveTeamToDatabase( DatabaseGatewayHelper.CreateTeamDatabaseEntity(new List <WorkerTeam>())); var response = _teamGateway.GetTeamByTeamId(team.Id); response.Should().BeEquivalentTo(team); }