public ElectionGuardController(ILogger <ElectionGuardController> logger, IElectionMapper <Election, Ballot, VoteTally> electionMapper, IConfigFileService configService) { _config = configService; _logger = logger; _electionMapper = electionMapper; _exportPath = Path.Combine(_config.GetDataDirectory(), "election_results"); logger.LogInformation($"DATA: resolved at: {_config.GetDataDirectory()}"); // try to load the election config files from the file system var election = _config.GetElection(); if (election != null) { logger.LogInformation("ElectionController: Found Election"); _election = election; _electionMap = _electionMapper.GetElectionMap(_election); } else { logger.LogInformation("ElectionController: Could not find election.json"); } var electionguardConfig = _config.getElectionGuardConfig(); if (electionguardConfig != null) { logger.LogInformation("ElectionController: Found ElectionGuard Config"); _electionGuardConfig = electionguardConfig; } else { logger.LogInformation("ElectionController: Could not find election.config.json"); } var now = DateTime.Now; _encryptedBallotsExportFileName = $"encrypted-ballots_{now.Year}_{now.Month}_{now.Day}"; _registeredBallotsExportFileNamePrefix = $"registered-ballots"; _tallyExportFileNamePrefix = "tally-results"; }
public void Setup() { _electionMapper = new VotingWorksMapper(); _yesNoElection = new Election() { Contests = new Contest[] { new YesNoContest { Id = "Contest1", DistrictId = "District1" }, new YesNoContest { Id = "Contest2", DistrictId = "District1" } }, BallotStyles = new [] { new BallotStyle { Id = "Style1", Districts = new [] { "District1" } } } }; var candidates = new[] { new Candidate { Id = "Fake 1" }, new Candidate { Id = "Fake 2" }, new Candidate { Id = "Fake 3" }, new Candidate { Id = "Fake 4" } }; var ballotStyles = new[] { new BallotStyle { Id = "Style1", Districts = new[] { "District1" } }, new BallotStyle { Id = "Style2", Districts = new[] { "District1", "District2" } } }; _candidateElection = new Election() { Contests = new Contest[] { new CandidateContest() { Id = "NormalContest", DistrictId = "District1", Seats = 1, AllowWriteIns = false, Candidates = candidates }, new CandidateContest() { Id = "NullVotesContest", DistrictId = "District1", Seats = 3, AllowWriteIns = false, Candidates = candidates }, new CandidateContest() { Id = "WriteInsContest", DistrictId = "District2", Seats = 1, AllowWriteIns = true, Candidates = candidates }, }, BallotStyles = ballotStyles }; _ballot = new Ballot { Election = _candidateElection, BallotId = "123", BallotType = BallotType.Standard, Votes = new Dictionary <string, object> { { "NormalContest", new [] { candidates[0] } }, { "NullVotesContest", new [] { candidates[0] } }, { "WriteInsContest", new [] { candidates[0] } } }, BallotStyle = ballotStyles[1] }; _nullBallot = new Ballot { Election = _candidateElection, BallotId = "123", BallotType = BallotType.Standard, Votes = new Dictionary <string, object> { { "NormalContest", new Candidate[] {} }, { "NullVotesContest", new Candidate[] {} }, { "WriteInsContest", new Candidate[] {} } }, BallotStyle = ballotStyles[1] }; }