public void QCumulativeTests(bool yesCheck, int firstVote, int secondVote, int thirdVote,
                                     bool noCheck, int noVotes,
                                     bool absCheck, int absVotes,
                                     AmountOfStockSubmited expected)
        {
            var allowedVotesAmount = new FractionLong(100);
            var qCum = new QCumulative(1,
                                       new List <QCumCandidatePoint>
            {
                new QCumCandidatePoint(1, Fields.VotesDocField(firstVote)),
                new QCumCandidatePoint(2, Fields.VotesDocField(secondVote)),
                new QCumCandidatePoint(3, Fields.VotesDocField(thirdVote)),
            },
                                       new QCumulativeAdditionalMarks(
                                           Fields.CheckBoxDocField(yesCheck),
                                           Fields.CheckBoxDocField(noCheck),
                                           Fields.VotesDocField(noVotes),
                                           Fields.CheckBoxDocField(absCheck),
                                           Fields.VotesDocField(absVotes))
                                       )
            {
                PositionsCount = 10
            };
            var result = _calculator.GetAmountOfStockSubmited(qCum, allowedVotesAmount);

            Assert.That(result, Is.EqualTo(expected));
        }
        public void QCumulativeCandidateVoteTests(bool yesCheck, long yesVotes, long expectedResultLong)
        {
            const bool doesntMatter2 = false;
            const long doesntMatter3 = 0;
            const int  doesntMatter4 = 0;
            const int  doesntMatter5 = 1;

            var candidatePoint = new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(yesVotes.FL()));


            var qCum = new QCumulative(doesntMatter5, new List <QCumCandidatePoint> {
                candidatePoint
            },
                                       new QCumulativeAdditionalMarks(Fields.CheckBoxDocField(yesCheck),
                                                                      Fields.CheckBoxDocField(doesntMatter2),
                                                                      Fields.VotesDocField(doesntMatter3.FL()),
                                                                      Fields.CheckBoxDocField(doesntMatter2),
                                                                      Fields.VotesDocField(doesntMatter3.FL(),
                                                                                           doesntMatter4)));

            var result   = _calculator.GetVotesForCandidateField(qCum, candidatePoint);
            var expected = new FractionLong(expectedResultLong);

            Assert.That(result, Is.EqualTo(expected));
        }
        private QCumulative GetQCumulative(ErrorLevel candidate1ErrorLevel, ErrorLevel candidate2ErrorLevel, ErrorLevel candidate3ErrorLevel, ErrorLevel candidate4ErrorLevel, ErrorLevel candidate5ErrorLevel, ErrorLevel yesCheckBoxErrorLevel, ErrorLevel noCheckBoxErrorLevel, ErrorLevel noVotesErrorLevel, ErrorLevel abstainedCheckBoxErrorLevel, ErrorLevel abstainedVotesErrorLevel)
        {
            #region doesnt matter constants

            const bool doesntmatter  = true;
            var        doesntmatter2 = FractionLong.Zero;
            const int  doesntMatter5 = 1;
            #endregion


            return(new QCumulative(
                       doesntMatter5,
                       new List <QCumCandidatePoint>
            {
                new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(doesntmatter2, candidate1ErrorLevel)),
                new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(doesntmatter2, candidate2ErrorLevel)),
                new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(doesntmatter2, candidate3ErrorLevel)),
                new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(doesntmatter2, candidate4ErrorLevel)),
                new QCumCandidatePoint(doesntMatter5, Fields.VotesDocField(doesntmatter2, candidate5ErrorLevel))
            },
                       new QCumulativeAdditionalMarks
                       (
                           Fields.CheckBoxDocField(doesntmatter, yesCheckBoxErrorLevel),
                           Fields.CheckBoxDocField(doesntmatter, noCheckBoxErrorLevel),
                           Fields.VotesDocField(doesntmatter2, abstainedCheckBoxErrorLevel),
                           Fields.CheckBoxDocField(doesntmatter, noVotesErrorLevel),
                           Fields.VotesDocField(doesntmatter2, abstainedVotesErrorLevel))
                       ));
        }
Beispiel #4
0
        private static QSepCandidatePoint GetCandidatePoint(ErrorLevel candidateYesCheckErrorLevel, ErrorLevel candidateNoCheckErrorLevel, ErrorLevel candidateAbsCheckErrorLevel, ErrorLevel candidateYesVotesErrorLevel, ErrorLevel candidateNoVotesErrorLevel, ErrorLevel candidateAbsVotesErrorLevel)
        {
            const bool doesntMatter  = false;
            var        doesntMatter2 = 0.FL();

            return(new QSepCandidatePoint(1,
                                          new BaseYesNoAbsPoint(
                                              Fields.CheckBoxDocField(doesntMatter, candidateYesCheckErrorLevel),
                                              Fields.CheckBoxDocField(doesntMatter, candidateNoCheckErrorLevel),
                                              Fields.CheckBoxDocField(doesntMatter, candidateAbsCheckErrorLevel),
                                              Fields.VotesDocField(doesntMatter2, candidateYesVotesErrorLevel),
                                              Fields.VotesDocField(doesntMatter2, candidateNoVotesErrorLevel),
                                              Fields.VotesDocField(doesntMatter2, candidateAbsVotesErrorLevel))));
        }
        public void InitBulletin()
        {
            Page1 = new Page(1);
            Page2 = new Page(2);
            Page3 = new Page(3);


            var questions = new List <Question>();

            QSimple1 = TestBulletinModel.GetFreshQSimple(Page1);
            QSimple2 = TestBulletinModel.GetFreshQSimple(Page1);
            QSimple3 = TestBulletinModel.GetFreshQSimple(Page1);
            questions.Add(QSimple1);
            questions.Add(QSimple2);
            questions.Add(QSimple3);


            QCumulative1 = TestBulletinModel.GetFreshQCumulative(Page2);
            QCumulative2 = TestBulletinModel.GetFreshQCumulative(Page2);
            questions.Add(QCumulative1);
            questions.Add(QCumulative2);

            QSeparate1 = TestBulletinModel.GetFreshQSeparate(Page3);
            QSeparate2 = TestBulletinModel.GetFreshQSeparate(Page3);
            questions.Add(QSeparate1);
            questions.Add(QSeparate2);

            const bool packetIsRegistered = true;

            Signature1 = new Signature(Fields.CheckBoxDocField(true, Page1), 1, 1, new List <Question> {
                QSimple1, QSimple2, QSimple3, QSeparate1
            });
            Signature2 = new Signature(Fields.CheckBoxDocField(true, Page2), 2, 2, new List <Question> {
                QSeparate2, QCumulative1
            });
            Signature3 = new Signature(Fields.CheckBoxDocField(true, Page3), 3, 3, new List <Question> {
                QCumulative2
            });

            var signatures = new List <Signature> {
                Signature1, Signature2, Signature3
            };

            Bulletin = TestBulletinModel.Create(questions, signatures, AllowedVotesAmount, PackStatus, TrustExists, packetIsRegistered);

            var graph = GraphProvider.BuildGraph(Bulletin);

            new GraphWalker().WalkThrough(graph, Bulletin);
        }
        public void BaseYesNoAbsPointTests(bool yesCheck, int yesVotes,
                                           bool noCheck, int noVotes,
                                           bool absCheck, int absVotes,
                                           AmountOfStockSubmited expected)
        {
            var allowedVotesAmount      = new FractionLong(100);
            var baseYesNoAbstainedPoint = new BaseYesNoAbsPoint(
                Fields.CheckBoxDocField(yesCheck),
                Fields.CheckBoxDocField(noCheck),
                Fields.CheckBoxDocField(absCheck),
                Fields.VotesDocField(yesVotes),
                Fields.VotesDocField(noVotes),
                Fields.VotesDocField(absVotes));
            var result = _calculator.GetAmountOfStockSubmited(baseYesNoAbstainedPoint, allowedVotesAmount);

            Assert.That(result, Is.EqualTo(expected));
        }
        public void TestFixtureSetUp()
        {
            #region doesnt matter constants
            const bool doesntmatter  = true;
            var        doesntmatter2 = FractionLong.Zero;
            #endregion

            _invalidQSimple1 = new QSimple(1,
                                           new BaseYesNoAbsPoint(
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Error),
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Error),
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Valid),
                                               Fields.VotesDocField(doesntmatter2),
                                               Fields.VotesDocField(doesntmatter2),
                                               Fields.VotesDocField(doesntmatter2)
                                               ));
            _validQSimple = new QSimple(2,
                                        new BaseYesNoAbsPoint(
                                            Fields.CheckBoxDocField(doesntmatter, ErrorLevel.WasntChecked),
                                            Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Valid),
                                            Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Valid),
                                            Fields.VotesDocField(doesntmatter2, ErrorLevel.WasntChecked),
                                            Fields.VotesDocField(doesntmatter2, ErrorLevel.Valid),
                                            Fields.VotesDocField(doesntmatter2, ErrorLevel.WasntChecked)
                                            ));
            _invalidQSimple2 = new QSimple(3,
                                           new BaseYesNoAbsPoint(
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Valid),
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.WasntChecked),
                                               Fields.CheckBoxDocField(doesntmatter, ErrorLevel.Valid),
                                               Fields.VotesDocField(doesntmatter2, ErrorLevel.Error),
                                               Fields.VotesDocField(doesntmatter2, ErrorLevel.WasntChecked),
                                               Fields.VotesDocField(doesntmatter2, ErrorLevel.WasntChecked)
                                               ));

            var bulletin = TestBulletinModel.Create(new List <Question>
            {
                _invalidQSimple1,
                _validQSimple,
                _invalidQSimple2,
            });

            var checker = new QuestionValidityChecker(new CandidateValidityChecker(), new AdrQuestionValidityChecker());
            _invalidQuestions = checker.GetInvalidQuestions(bulletin);
        }
 private static CheckBoxDocField DefaultCheckbox()
 {
     return(Fields.CheckBoxDocField(true));
 }