public void GetActive_Puzzel_existingTeam() { var _LocalfakeTeamRepo = new TeamRepositoryFake(); var spelerMock = new Mock <ISpelerRepository>(); var sessieMock = new Mock <ISessionRepository>(); var teamMock = new Mock <ITeamRepository>(); var puzzelMock = new Mock <IPuzzelRepository>(); teamMock.Setup(t => t.GetTeams()).Returns(_LocalfakeTeamRepo.GetTeams()); teamMock.Setup(t => t.GetTeam(It.IsIn(1, 2))).Returns((int id) => { return(GameDBFake.teams.Where(g => g.Id == id).FirstOrDefault()); }); teamMock.Setup(t => t.GetTeam(It.IsNotIn(1, 2))).Returns((Team)null); teamMock.Setup(t => t.GetActivePuzzel(2)).Returns((int id) => { return(GameDBFake.teams.Where(g => g.Id == id).FirstOrDefault().ActivePuzzel); }); teamMock.Setup(t => t.GetActivePuzzel(1)).Returns((int id) => { return(-1); }); puzzelMock.Setup(p => p.GetPuzzel(It.IsAny <int>())).Returns(new Puzzel()); var team = new TeamService(teamMock.Object, spelerMock.Object, sessieMock.Object, puzzelMock.Object); //Arrange var teamIdActive = 2; //team 2 is bezig met een actieve puzzel var teamIdNotActive = 1; //team1 is niet bezig met een puzzel // Act var resultActive = team.ActivePuzzel(teamIdActive); var resultNotActive = team.ActivePuzzel(teamIdNotActive); var activepuzzelID = team.GetActivePuzzel(1); // Assert Assert.IsType <Puzzel>(resultActive); Assert.Equal(-1, activepuzzelID); Assert.Null(resultNotActive); }
public void GetActive_Puzzel_NotexistingTeam() { var spelerMock = new Mock <ISpelerRepository>(); var sessieMock = new Mock <ISessionRepository>(); var teamMock = new Mock <ITeamRepository>(); var puzzelMock = new Mock <IPuzzelRepository>(); teamMock.Setup(t => t.GetTeams()).Returns(_fakeTeamRepo.GetTeams()); teamMock.Setup(t => t.GetTeam(It.IsIn(1, 2))).Returns((int i) => _fakeTeamRepo.GetTeam(i)); teamMock.Setup(t => t.GetTeam(It.IsNotIn(1, 2))).Returns((Team)null); puzzelMock.Setup(p => p.GetPuzzel(It.IsAny <int>())).Returns(new Puzzel()); var team = new TeamService(teamMock.Object, spelerMock.Object, sessieMock.Object, puzzelMock.Object); //Arrange var teamId = 99999; // Act var result = team.ActivePuzzel(teamId); // Assert Assert.Null(result); }