Exemplo n.º 1
0
        public void VoteOnPresidentCandidateTest()
        {
            bool          saveChangesCalled = false;
            PresidentVote addedVote         = null;

            presidentVotingRepository.Setup(x => x.AddVote(It.IsAny <PresidentVote>()))
            .Callback <PresidentVote>(v => addedVote = v);

            presidentVotingRepository.Setup(x => x.SaveChanges())
            .Callback(() => saveChangesCalled = true);

            var country = new CountryDummyCreator()
                          .SetPresidentVotingStatus(GameHelper.CurrentDay, VotingStatusEnum.Ongoing)
                          .Create();

            var citizen = new CitizenDummyCreator()
                          .SetCountry(country)
                          .Create();

            var candidateCitizen = new CitizenDummyCreator()
                                   .SetCountry(country)
                                   .Create();

            var voting = country.PresidentVotings.Last();

            var candidate = new PresidentCandidateDummyCreator()
                            .Create(voting);

            countrySerivce.VoteOnPresidentCandidate(citizen, candidate);

            Assert.IsTrue(saveChangesCalled);
            Assert.AreEqual(citizen.ID, addedVote.CitizenID);
            Assert.AreEqual(candidate.ID, addedVote.CandidateID);
            Assert.AreEqual(voting.ID, addedVote.PresidentVotingID);
        }
Exemplo n.º 2
0
        public void VoteOnPresidentCandidate(Citizen citizen, PresidentCandidate candidate)
        {
            var vote = new PresidentVote()
            {
                CandidateID       = candidate.ID,
                CitizenID         = citizen.ID,
                PresidentVotingID = candidate.VotingID
            };

            presidentVotingRepository.AddVote(vote);
            presidentVotingRepository.SaveChanges();
        }
Exemplo n.º 3
0
        public PresidentVote Create(PresidentCandidate candidate)
        {
            presidentVote.PresidentCandidate = candidate;
            presidentVote.PresidentVoting    = candidate.PresidentVoting;
            presidentVote.PresidentVotingID  = candidate.VotingID;
            presidentVote.CandidateID        = candidate.ID;
            candidate.PresidentVotes.Add(presidentVote);
            candidate.PresidentVoting.PresidentVotes.Add(presidentVote);

            var _return = presidentVote;

            presidentVote = createVote();
            return(_return);
        }
Exemplo n.º 4
0
        private PresidentVote createVote()
        {
            var citizen = citizenGenerator.Create();

            var vote = new PresidentVote()
            {
                ID        = idGenerator.UniqueID,
                Citizen   = citizen,
                CitizenID = citizen.ID
            };

            citizen.PresidentVotes.Add(vote);

            return(vote);
        }
Exemplo n.º 5
0
 public void AddVote(PresidentVote vote)
 {
     context.PresidentVotes.Add(vote);
 }
Exemplo n.º 6
0
 public PresidentVoteDummyGenerator()
 {
     presidentVote = createVote();
 }