public void UpdateChallengeTest()
        {
            //Arrange
            Data.Entities.HLContext _db    = new Data.Entities.HLContext();
            ChallengeRepository     ChRepo = new ChallengeRepository(_db);
            TeamRepository          TRepo  = new TeamRepository(_db);
            bool      updateSuccess;
            Challenge outCha;

            Team team1 = new Team();

            team1.teamname = "Test1";
            TRepo.AddTeam(team1);
            Team Test1 = TRepo.GetByTeamName(team1.teamname);

            Team team2 = new Team();

            team2.teamname = "Test2";
            TRepo.AddTeam(team2);
            Team Test2 = TRepo.GetByTeamName(team2.teamname);


            Challenge cha1 = new Challenge(Test1, Test2, 1);

            ChRepo.AddChallenge(cha1);
            Challenge pullCha = ChRepo.GetTeamChallenges(team1.teamname).FirstOrDefault();

            pullCha.MakeReport(pullCha.Team1.teamname, true);
            pullCha.MakeReport(pullCha.Team2.teamname, false);

            //Act
            updateSuccess = ChRepo.UpdateChallenge(pullCha);
            outCha        = ChRepo.GetTeamChallenges(team1.teamname).FirstOrDefault();

            List <Challenge> tempChas = ChRepo.GetTeamChallenges(team1.teamname);

            foreach (var cha in tempChas)
            {
                ChRepo.DeleteChallenge(cha);
            }
            TRepo.DeleteTeam(team1);
            TRepo.DeleteTeam(team2);

            //Assert
            Assert.IsTrue(updateSuccess);
            Assert.IsTrue((bool)outCha.Team1Report);
            Assert.IsFalse((bool)outCha.Team2Report);
        }
예제 #2
0
        public void UpdateChallenge(int id, ChallengeCreation update)
        {
            var challenge = _mapper.Map <Challenge>(update);

            _challengeRepository.UpdateChallenge(id, challenge);
        }