public void ResultModify_WhenCommandApplied_ValidModifiedLineItemAdded() { var result = new SenatorialResult(); CreateSenatorialResultCommand cmdCreate = DefaultCreateSenatorialResultCommand(); result.Apply(cmdCreate); AddSenatorialLineItemsCommand cmdLineItem = DefaultAddSenatorialLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender); result.Apply(cmdLineItem); ConfirmSenatorialResultsCommand cmdConfirm = DefaultConfirmPresidentalResultsCommand(3, cmdLineItem.ApplyToResult, result.PollingCentre, result.ResultSender); result.Apply(cmdConfirm); ModifySenatorialResultsCommand cmd = DefaultModifySenatorialResultsCommand(4, cmdConfirm.ApplyToResult, result.PollingCentre, result.ResultSender); //act result.Apply(cmd); //assert Assert.That(result.LineItems.Count(), Is.EqualTo(2)); Assert.That(result.Id, Is.EqualTo(cmd.ApplyToResult.Id)); Assert.That(result.Status, Is.EqualTo(ResultStatus.Modified)); SenatorialResultLineItem lineItem = result.LineItems[1]; Assert.That(lineItem.Candidate, Is.EqualTo(cmd.ResultDetail[0].Candidate)); Assert.That(lineItem.ResultCount, Is.EqualTo(cmd.ResultDetail[0].Result)); }
public void ResultConfirm_WhenCommandApplied_ResultStatusConfirmed() { var result = new SenatorialResult(); CreateSenatorialResultCommand cmdCreate = DefaultCreateSenatorialResultCommand(); result.Apply(cmdCreate); AddSenatorialLineItemsCommand cmdLineItem = DefaultAddSenatorialLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender); result.Apply(cmdLineItem); ConfirmSenatorialResultsCommand cmd = DefaultConfirmPresidentalResultsCommand(3, cmdLineItem.ApplyToResult, result.PollingCentre, result.ResultSender); //act result.Apply(cmd); //assert Assert.That(result.Status, Is.EqualTo(ResultStatus.Confirmed)); }
public void ResultAddLineItem_WhenCommandApplied_ValidLineItemAdded() { var result = new SenatorialResult(); CreateSenatorialResultCommand cmdCreate = DefaultCreateSenatorialResultCommand(); result.Apply(cmdCreate); AddSenatorialLineItemsCommand cmd = DefaultAddSenatorialLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender); //act result.Apply(cmd); //assert Assert.That(result.LineItems.Count(), Is.EqualTo(1)); Assert.That(result.Id, Is.EqualTo(cmd.ApplyToResult.Id)); Assert.That(result.Status, Is.EqualTo(ResultStatus.New)); SenatorialResultLineItem lineItem = result.LineItems[0]; Assert.That(lineItem.Candidate, Is.EqualTo(cmd.ResultDetail[0].Candidate)); Assert.That(lineItem.ResultCount, Is.EqualTo(cmd.ResultDetail[0].Result)); }
public SenatorialResult AddSenatorialResultLineItems(SenatorialResult result, ResultInfo originatingInfo, List <ResultDetail> resultDetails) { CommandInfo commandInfo = new CommandInfo { CommandGeneratedByUser = originatingInfo.CommandGeneratedByUser, OriginatingPollingCentre = originatingInfo.OriginatingPollingCentre, }; var command = new AddSenatorialLineItemsCommand { CommandId = Guid.NewGuid(), CommandGeneratedByUser = commandInfo.CommandGeneratedByUser, OriginatingPollingCentre = commandInfo.OriginatingPollingCentre, ApplyToResult = result.GetResultRef(), CommandExecutionOrder = result.LastResultCommandExecutedOrder + 1, ResultDetail = resultDetails, }; result.Apply(command); return(result); }
private AddSenatorialLineItemsCommand DefaultAddSenatorialLineItemsCommand(int executionOrder, ResultRef result, PollingCentreRef pollingCentre, UserRef user) { var fixture = new Fixture(); AddSenatorialLineItemsCommand cmd = fixture .Build <AddSenatorialLineItemsCommand>() .With(n => n.ApplyToResult, result) .Create(); cmd.CommandId = Guid.NewGuid(); cmd.ApplyToResult = result; CandidateRef candidate = new CandidateRef(Guid.NewGuid(), "Mike Sonko", CandidateType.PartyBacked); var res = new ResultDetail { Candidate = candidate, Result = 1000 }; var resList = new List <ResultDetail>(); resList.Add(res); cmd.ResultDetail = resList; cmd.OriginatingPollingCentre = pollingCentre; cmd.CommandGeneratedByUser = user; cmd.CommandExecutionOrder = executionOrder; return(cmd); }