Exemplo n.º 1
0
        public IActionResult ElectionResult(int id)
        {
            // Get the Position details
            Position position = _repository.GetPosition(id);

            // Calculate the election results
            IVotingCalculator calculator;

            switch (position.Election.VotingMethod)
            {
            case VotingMethod.FullPreferential:
                calculator = new FPVotingCalculator(_repository);
                break;

            case VotingMethod.OptionalPreferential:
                calculator = new OPVotingCalculator(_repository);
                break;

            default:     // VotingMethod.FirstPastThePost:
                calculator = new FPTPVotingCalculator(_repository);
                break;
            }

            return(View(calculator.CalculateElectionResult(id)));
        }
        public void Test1()
        {
            IVotingCalculator calculator = new FPTPVotingCalculator(_repository);
            ElectionResult    result     = calculator.CalculateElectionResult(1);

            Assert.NotNull(result);
        }