Ejemplo n.º 1
0
        public void SetActive_Puzzel_NotexistingTeam()
        {
            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 i) => _LocalfakeTeamRepo.GetTeam(i));
            teamMock.Setup(t => t.SetActivePuzzel(It.IsIn(1, 2), It.IsAny <int>())).Callback <int, int>((a, b) => _LocalfakeTeamRepo.SetActivePuzzel(a, b));
            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 = 9999;

            // Act
            var result   = team.SetActivePuzzel(teamId, false);
            var resultId = team.ActivePuzzelID(teamId);

            // Assert
            Assert.Equal(-1, resultId);
            Assert.Null(result);
        }
Ejemplo n.º 2
0
        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);
        }