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(), "Sonko", CandidateType.PartyBacked), Result = 1000
            };
            ResultDetail resultDetail1 = new ResultDetail {
                Candidate = new CandidateRef(Guid.NewGuid(), "Waititu", CandidateType.PartyBacked), Result = 2000
            };
            List <ResultDetail> resultDetails = new List <ResultDetail>();

            resultDetails.Add(resultDetail);
            resultDetails.Add(resultDetail1);
            ISenatorialResultService    senatorialResultService    = _ioc.Resolve <ISenatorialResultService>();
            ISenatorialResultRepository senatorialResultRepository = _ioc.Resolve <ISenatorialResultRepository>();

            //Act
            senatorialResultService.Excecute(user, pollingCentre, resultDetails);
            //Assert
            var senatorialResult = senatorialResultRepository.GetAll().OrderByDescending(n => n.ResultSendDate).First();

            Assert.That(senatorialResult.Id, Is.Not.EqualTo(Guid.Empty));
            Assert.IsNotNull(senatorialResult.ResultReference);
            Assert.That(senatorialResult.ResultSender, Is.EqualTo(user));
            Assert.That(senatorialResult.PollingCentre, Is.EqualTo(pollingCentre));
            Assert.That(senatorialResult.Status, Is.EqualTo(ResultStatus.Confirmed));
            Assert.That(senatorialResult.ResultSender, Is.EqualTo(user));
            Assert.That(senatorialResult.LineItems.OrderBy(n => n.Candidate.FullName).First().Candidate, Is.EqualTo(resultDetail.Candidate));
            Assert.That(senatorialResult.LineItems.OrderBy(n => n.Candidate.FullName).Last().Candidate, Is.EqualTo(resultDetail1.Candidate));
            Assert.That(senatorialResult.LineItems.OrderBy(n => n.Candidate.FullName).First().ResultCount, Is.EqualTo(resultDetail.Result));
            Assert.That(senatorialResult.LineItems.OrderBy(n => n.Candidate.FullName).Last().ResultCount, Is.EqualTo(resultDetail1.Result));
        }
 public SenatorialResultService(ISenatorialResultRepository senatorialResultRepository, ISenatorialResultWorkflow senatorialResultWorkflow)
 {
     _senatorialResultRepository = senatorialResultRepository;
     _senatorialResultWorkflow   = senatorialResultWorkflow;
 }