コード例 #1
0
        public void Simple_Status_Constituency()
        {
            ICountyRepository countyRepository = Substitute.For <ICountyRepository>();
            var f            = new Fixture();
            var county       = f.Create <County>();
            var constituency = CreateConstituency(county.GetMasterDataRef());

            countyRepository.GetById(Arg.Any <Guid>()).Returns(county);
            var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository);

            constituencyRepository.Save(constituency);
            constituencyRepository.SetInactive(constituency);
            var inactive = constituencyRepository.GetById(constituency.Id);

            Assert.That(inactive.Status == EntityStatus.Inactive);

            constituencyRepository.SetActive(constituency);
            var active = constituencyRepository.GetById(constituency.Id);

            Assert.That(active.Status == EntityStatus.Active);

            constituencyRepository.SetAsDeleted(constituency);
            var deleted = constituencyRepository.GetById(constituency.Id);

            Assert.That(deleted.Status == EntityStatus.Deleted);
        }
コード例 #2
0
        public static void Seed(EvotingContext context)
        {
            const int count                  = 5;
            var       candidates             = new List <Candidate>();
            var       constituencyRepository = new ConstituencyRepository(context);
            var       partyRepository        = new PartyRepository(context);


            for (var i = 1; i <= count; i++)
            {
                var constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5));
                var party        = partyRepository.GetPartyById(Faker.RandomNumber.Next(1, 5));

                var candidate = new Candidate
                {
                    Constituency = constituency,
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    NumVotes     = 0,
                    Party        = party
                };
                candidates.Add(candidate);
            }
            candidates.ForEach(c => context.Candidates.Add(c));
            context.SaveChanges();
        }
コード例 #3
0
        public static void Seed(EvotingContext context)
        {
            var constituencyRepository = new ConstituencyRepository(context);
            var voters = new List <Voter>
            {
                new Voter
                {
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    Username     = Faker.Internet.UserName(),
                    Role         = Voter.ROLE,
                    Password     = "******",
                    Constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5))
                },
                new Voter
                {
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    Username     = Faker.Internet.UserName(),
                    Role         = Voter.ROLE,
                    Password     = "******",
                    Constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5))
                },
                new Voter
                {
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    Username     = Faker.Internet.UserName(),
                    Role         = Voter.ROLE,
                    Password     = "******",
                    Constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5))
                },
                new Voter
                {
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    Username     = Faker.Internet.UserName(),
                    Role         = Voter.ROLE,
                    Password     = "******",
                    Constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5))
                },
                new Voter
                {
                    FirstName    = Faker.Name.First(),
                    LastName     = Faker.Name.Last(),
                    Username     = Faker.Internet.UserName(),
                    Role         = Voter.ROLE,
                    Password     = "******",
                    Constituency = constituencyRepository.GetConstituencyById(Faker.RandomNumber.Next(1, 5))
                }
            };

            voters.ForEach(v => context.Users.Add(v));
            context.SaveChanges();
        }
コード例 #4
0
        public void SimpeHydrate_Constituency()
        {
            ICountyRepository countyRepository = Substitute.For <ICountyRepository>();
            var f            = new Fixture();
            var county       = f.Create <County>();
            var constituency = CreateConstituency(county.GetMasterDataRef());

            countyRepository.GetById(Arg.Any <Guid>()).Returns(county);
            var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository);
            var id = constituencyRepository.Save(constituency);

            Assert.IsNotNull(id);
            Assert.AreEqual(id, constituency.Id);
        }
コード例 #5
0
        public void SimpeDeHydrateAll_Constituency()
        {
            ICountyRepository countyRepository = Substitute.For <ICountyRepository>();
            var f            = new Fixture();
            var county       = f.Create <County>();
            var constituency = CreateConstituency(county.GetMasterDataRef());

            countyRepository.GetById(Arg.Any <Guid>()).Returns(county);
            var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository);

            constituencyRepository.Save(constituency);
            var owner = constituencyRepository.GetAll();

            Assert.That(owner.Any());
        }
コード例 #6
0
 public ConstituenciesController()
 {
     _constituencyRepository = new ConstituencyRepository(db);
 }
コード例 #7
0
 public VotePledgeController(ElectionContext electionContext)
 {
     this.constituencyRepository = new ConstituencyRepository(electionContext);
 }