public void PresidentVotingSameNumberOfVotes() { var countryCreator = new CountryDummyCreator(); var candidatesCreator = new PresidentCandidateDummyCreator(); candidatesCreator.setVotesNumber(10); countryCreator.VotingCreator.SetState(GameHelper.CurrentDay, VotingStatusEnum.Ongoing); var country = countryCreator.Create(); var citizenCreator = new CitizenDummyCreator(); var voting = country.PresidentVotings.Last(); for (int i = 0; i < 5; ++i) { var candidate = candidatesCreator.Create(voting); voting.PresidentCandidates.Add(candidate); candidates.Add(candidate); } PresidentVoting newVoting = null; presidentVotingRepository.Setup(x => x.Add(It.IsAny <PresidentVoting>())) .Callback <PresidentVoting>(v => newVoting = v); countrySerivce.ProcessPresidentVoting(GameHelper.CurrentDay, country, voting); Assert.IsTrue(country.PresidentID == null); Assert.IsTrue(voting.VotingStatusID == (int)VotingStatusEnum.Finished); Assert.IsTrue(voting != newVoting && newVoting != null); Assert.IsTrue(newVoting.StartDay > GameHelper.CurrentDay); Assert.IsTrue(newVoting.VotingStatusID == (int)VotingStatusEnum.NotStarted); }
public void PresidentVotingCandidateWinningTest() { var countryCreator = new CountryDummyCreator(); var candidatesCreator = new PresidentCandidateDummyCreator(); countryCreator.VotingCreator.SetState(GameHelper.CurrentDay, VotingStatusEnum.Ongoing); var country = countryCreator.Create(); var citizenCreator = new CitizenDummyCreator(); var voting = country.PresidentVotings.Last(); PresidentCandidate lastCandidate = null; for (int i = 0; i < 5; ++i) { candidatesCreator.setVotesNumber(10 + i); var candidate = candidatesCreator.Create(voting); voting.PresidentCandidates.Add(candidate); lastCandidate = candidate; candidates.Add(candidate); } PresidentVoting newVoting = null; presidentVotingRepository.Setup(x => x.Add(It.IsAny <PresidentVoting>())) .Callback <PresidentVoting>(v => newVoting = v); countrySerivce.ProcessPresidentVoting(GameHelper.CurrentDay, country, voting); Assert.IsTrue(country.PresidentID == lastCandidate.CandidateID); Assert.IsTrue(lastCandidate.CandidateStatusID == (int)PresidentCandidateStatusEnum.Approved); Assert.IsTrue(voting.VotingStatusID == (int)VotingStatusEnum.Finished); Assert.IsTrue(voting != newVoting && newVoting != null); Assert.IsTrue(newVoting.StartDay > GameHelper.CurrentDay); Assert.IsTrue(newVoting.VotingStatusID == (int)VotingStatusEnum.NotStarted); foreach (var candidate in candidates) { if (candidate != lastCandidate) { Assert.IsTrue(candidate.CandidateStatusID == (int)PresidentCandidateStatusEnum.Rejected); } } }