コード例 #1
0
        public void ResultProcessing_WhenReceived_ValidResultSaved()
        {
            //Arrange
            UserRef          user          = new UserRef(Guid.NewGuid(), "Brian Mwasi", UserType.Clerk);
            PollingCentreRef pollingCentre = new PollingCentreRef(Guid.NewGuid(), "Jamuhuri Primary");
            ResultDetail     resultDetail  = new ResultDetail {
                Candidate = new CandidateRef(Guid.NewGuid(), "Athanus", CandidateType.PartyBacked), Result = 1000
            };
            ResultDetail resultDetail1 = new ResultDetail {
                Candidate = new CandidateRef(Guid.NewGuid(), "Ruth", CandidateType.PartyBacked), Result = 2000
            };
            List <ResultDetail> resultDetails = new List <ResultDetail>();

            resultDetails.Add(resultDetail);
            resultDetails.Add(resultDetail1);
            IMcaResultService    mcaResultService    = _ioc.Resolve <IMcaResultService>();
            IMcaResultRepository mcaResultRepository = _ioc.Resolve <IMcaResultRepository>();

            //Act
            mcaResultService.Excecute(user, pollingCentre, resultDetails);
            //Assert
            var mcaResult = mcaResultRepository.GetAll().OrderByDescending(n => n.ResultSendDate).First();

            Assert.That(mcaResult.Id, Is.Not.EqualTo(Guid.Empty));
            Assert.IsNotNull(mcaResult.ResultReference);
            Assert.That(mcaResult.ResultSender, Is.EqualTo(user));
            Assert.That(mcaResult.PollingCentre, Is.EqualTo(pollingCentre));
            Assert.That(mcaResult.Status, Is.EqualTo(ResultStatus.Confirmed));
            Assert.That(mcaResult.ResultSender, Is.EqualTo(user));
            Assert.That(mcaResult.LineItems.OrderBy(n => n.Candidate.FullName).First().Candidate, Is.EqualTo(resultDetail.Candidate));
            Assert.That(mcaResult.LineItems.OrderBy(n => n.Candidate.FullName).Last().Candidate, Is.EqualTo(resultDetail1.Candidate));
            Assert.That(mcaResult.LineItems.OrderBy(n => n.Candidate.FullName).First().ResultCount, Is.EqualTo(resultDetail.Result));
            Assert.That(mcaResult.LineItems.OrderBy(n => n.Candidate.FullName).Last().ResultCount, Is.EqualTo(resultDetail1.Result));
        }
コード例 #2
0
 public McaResultService(IMcaResultRepository mcaResultRepository, IMcaResultWorkflow mcaResultWorkflow)
 {
     _mcaResultRepository = mcaResultRepository;
     _mcaResultWorkflow   = mcaResultWorkflow;
 }