Ejemplo n.º 1
0
        public void ResultModify_WhenCommandApplied_ValidModifiedLineItemAdded()
        {
            var result = new ReferendumResult();
            CreateReferendumResultCommand cmdCreate = DefaultCreateReferendumResultCommand();

            result.Apply(cmdCreate);
            AddReferendumLineItemsCommand cmdLineItem = DefaultAddReferendumLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender);

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

            result.Apply(cmdConfirm);
            ModifyReferendumResultsCommand cmd = DefaultModifyReferendumResultsCommand(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));
            ReferendumResultLineItem lineItem = result.LineItems[1];

            Assert.That(lineItem.Candidate, Is.EqualTo(cmd.ResultDetail[0].Candidate));
            Assert.That(lineItem.ResultCount, Is.EqualTo(cmd.ResultDetail[0].Result));
        }
Ejemplo n.º 2
0
        public void ResultConfirm_WhenCommandApplied_ResultStatusConfirmed()
        {
            var result = new ReferendumResult();
            CreateReferendumResultCommand cmdCreate = DefaultCreateReferendumResultCommand();

            result.Apply(cmdCreate);
            AddReferendumLineItemsCommand cmdLineItem = DefaultAddReferendumLineItemsCommand(2, cmdCreate.ApplyToResult, result.PollingCentre, result.ResultSender);

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

            //act
            result.Apply(cmd);
            //assert
            Assert.That(result.Status, Is.EqualTo(ResultStatus.Confirmed));
        }
Ejemplo n.º 3
0
        public void ResultCreation_WhenCommandApplied_ValidNewResult()
        {
            var result = new ReferendumResult();
            CreateReferendumResultCommand cmd = DefaultCreateReferendumResultCommand();

            //act
            result.Apply(cmd);
            //assert
            Assert.That(result.Id, Is.Not.EqualTo(Guid.Empty));
            Assert.That(result.Id, Is.EqualTo(cmd.ApplyToResult.Id));
            Assert.That(result.Status, Is.EqualTo(ResultStatus.New));
            Assert.That(result.ResultReference, Is.EqualTo(cmd.ResultReference));
            Assert.That(result.PollingCentre, Is.EqualTo(cmd.OriginatingPollingCentre));
            Assert.That(result.ResultSender, Is.EqualTo(cmd.CommandGeneratedByUser));
            Assert.That(result.LineItems.Count(), Is.EqualTo(0));
        }
Ejemplo n.º 4
0
        public void ResultAddLineItem_WhenCommandApplied_ValidLineItemAdded()
        {
            var result = new ReferendumResult();
            CreateReferendumResultCommand cmdCreate = DefaultCreateReferendumResultCommand();

            result.Apply(cmdCreate);
            AddReferendumLineItemsCommand cmd = DefaultAddReferendumLineItemsCommand(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));
            ReferendumResultLineItem lineItem = result.LineItems[0];

            Assert.That(lineItem.Candidate, Is.EqualTo(cmd.ResultDetail[0].Candidate));
            Assert.That(lineItem.ResultCount, Is.EqualTo(cmd.ResultDetail[0].Result));
        }
Ejemplo n.º 5
0
        public ReferendumResult Create(ResultInfo originatingInfo, string documentReference)
        {
            CommandInfo commandInfo = new CommandInfo
            {
                CommandGeneratedByUser   = originatingInfo.CommandGeneratedByUser,
                OriginatingPollingCentre = originatingInfo.OriginatingPollingCentre,
                ResultReference          = documentReference
            };
            CreateReferendumResultCommand createReferendumResultCommand = new CreateReferendumResultCommand
            {
                CommandId = Guid.NewGuid(),
                CommandGeneratedByUser   = commandInfo.CommandGeneratedByUser,
                OriginatingPollingCentre = commandInfo.OriginatingPollingCentre,
                ApplyToResult            = new ResultRef(Guid.NewGuid(), ResultType.Referendum),
                ResultReference          = commandInfo.ResultReference,
                ResultDate            = DateTime.Now,
                CommandExecutionOrder = 1
            };
            var result = new ReferendumResult();

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