Exemple #1
0
        public void ResultModify_WhenCommandApplied_ValidModifiedLineItemAdded()
        {
            var result = new WomenRepResult();
            CreateWomenRepResultCommand cmdCreate = DefaultCreateWomenRepResultCommand();

            result.Apply(cmdCreate);
            AddWomenRepLineItemsCommand cmdLineItem = DefaultAddWomenRepLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender);

            result.Apply(cmdLineItem);
            ConfirmWomenRepResultsCommand cmdConfirm = DefaultConfirmPresidentalResultsCommand(3, cmdLineItem.ApplyToResult, result.PollingCentre, result.ResultSender);

            result.Apply(cmdConfirm);
            ModifyWomenRepResultsCommand cmd = DefaultModifyWomenRepResultsCommand(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));
            WomenRepResultLineItem lineItem = result.LineItems[1];

            Assert.That(lineItem.Candidate, Is.EqualTo(cmd.ResultDetail[0].Candidate));
            Assert.That(lineItem.ResultCount, Is.EqualTo(cmd.ResultDetail[0].Result));
        }
Exemple #2
0
        public void ResultConfirm_WhenCommandApplied_ResultStatusConfirmed()
        {
            var result = new WomenRepResult();
            CreateWomenRepResultCommand cmdCreate = DefaultCreateWomenRepResultCommand();

            result.Apply(cmdCreate);
            AddWomenRepLineItemsCommand cmdLineItem = DefaultAddWomenRepLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender);

            result.Apply(cmdLineItem);
            ConfirmWomenRepResultsCommand cmd = DefaultConfirmPresidentalResultsCommand(3, cmdLineItem.ApplyToResult, result.PollingCentre, result.ResultSender);

            //act
            result.Apply(cmd);
            //assert
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Confirmed));
        }
Exemple #3
0
        public WomenRepResult Confirm(WomenRepResult result, ResultInfo originatingInfo)
        {
            CommandInfo commandInfo = new CommandInfo
            {
                CommandGeneratedByUser   = originatingInfo.CommandGeneratedByUser,
                OriginatingPollingCentre = originatingInfo.OriginatingPollingCentre,
            };
            ConfirmWomenRepResultsCommand confirmWomenRepResultsCommand = new ConfirmWomenRepResultsCommand
            {
                CommandId = Guid.NewGuid(),
                CommandGeneratedByUser   = commandInfo.CommandGeneratedByUser,
                OriginatingPollingCentre = commandInfo.OriginatingPollingCentre,
                ApplyToResult            = result.GetResultRef(),
                CommandExecutionOrder    = result.LastResultCommandExecutedOrder + 1,
            };

            result.Apply(confirmWomenRepResultsCommand);
            return(result);
        }