Ejemplo n.º 1
0
        private CongressCandidateVoting CreateNewCongressCandidateVoting(Entities.Country country, int votingDay)
        {
            var voting = new CongressCandidateVoting()
            {
                CountryID      = country.ID,
                VotingDay      = votingDay,
                VotingStatusID = (int)VotingStatusEnum.NotStarted
            };

            congressCandidateVotingRepository.Add(voting);
            congressCandidateVotingRepository.SaveChanges();

            return(voting);
        }
Ejemplo n.º 2
0
        public void CreateNewCountryTest()
        {
            var param = new CreateCountryParameters()
            {
                CountryName       = "Test Country",
                CurrencyName      = "Test",
                CurrencyShortName = "TST",
                CurrencySymbol    = "T"
            };

            Country                 createdCountry = null;
            PresidentVoting         createdVoting  = null;
            CongressCandidateVoting congressVoting = null;

            presidentVotingRepository.Setup(x => x.Add(It.IsAny <PresidentVoting>()))
            .Callback <PresidentVoting>(v => createdVoting = v);

            countryRepository.Setup(x => x.Add(It.IsAny <Country>()))
            .Callback <Country>(c => {
                createdCountry = c;
                c.CountryPolicy.CongressCadenceLength  = 7;
                c.CountryPolicy.PresidentCadenceLength = 7;
            });

            congressCandidateVotingRepository.Setup(x => x.Add(It.IsAny <CongressCandidateVoting>()))
            .Callback <CongressCandidateVoting>(v => congressVoting = v);

            var country = countrySerivce.CreateCountry(param);



            entityRepository.Verify(x => x.Add(It.Is <Entity>(e => e.Name == param.CountryName)), Times.Once);
            Assert.AreEqual(param.CurrencyName, createdCountry.Currency.Name);
            Assert.AreEqual(param.CurrencyShortName, createdCountry.Currency.ShortName);
            Assert.AreEqual(param.CurrencySymbol, createdCountry.Currency.Symbol);

            Assert.IsTrue(createdVoting.StartDay > GameHelper.CurrentDay);
            Assert.IsTrue(congressVoting.VotingDay > GameHelper.CurrentDay);
        }
 public static bool HasVoted(this CongressCandidateVoting voting, Citizen citizen)
 {
     return(voting.CongressCandidateVotes
            .Any(v => v.CitizenID == citizen.ID));
 }
 public static bool Is(this CongressCandidateVoting voting, VotingStatusEnum votingStatus)
 {
     return(voting.VotingStatusID == (int)votingStatus);
 }
 public bool CanVote(Citizen citizen, CongressCandidateVoting voting)
 {
     return(voting.CongressCandidateVotes
            .Any(v => v.CitizenID == citizen.ID) == false);
 }