Beispiel #1
0
        public void CountScore_CountOfEvaluatedTips()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3);

            //verify
            Assert.That(result.Count, Is.EqualTo(2), "Count of evaluated tips must fit the count of provided tips.");
        }
Beispiel #2
0
        public void CountScore_ReturnsTypeOfEvaluatedTips()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3);

            //verify
            Assert.That(result, Is.TypeOf <EvaluatedTips>());
        }
Beispiel #3
0
        public void CountScore_ResultDoesNotContainNotExistingTipperName()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3);

            //verify
            string notExistingTipperName = "NoSuchTipper";

            Assert.IsFalse(result.Any(x => x.TipperName.Equals(notExistingTipperName)),
                           $"Evaluated tips must NOT contain a tip with TipperName {notExistingTipperName}.");
        }
Beispiel #4
0
        public void CountScore_ResultsAreOrderedFromBestScore()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3).OrderBy(x => x.Score).ToList();

            //verify
            Assert.That(result[0].Score, Is.EqualTo(-10),
                        $"On first position must be tipper with best score.");
            Assert.That(result[1].Score, Is.EqualTo(15),
                        $"On second position must be tipper with second best score.");
        }
Beispiel #5
0
        public void CountScore_ScoreIsCountedCorrectly()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3);

            //verify
            Assert.That(result[0].Score, Is.EqualTo(15),
                        $"Score for tipper '{result[0].TipperName}' not counted correctly.");
            Assert.That(result[1].Score, Is.EqualTo(-10),
                        $"Score for tipper '{result[1].TipperName}' not counted correctly.");
        }
Beispiel #6
0
        public void CountScore_ResultContainsNameOfTipper()
        {
            //prepare
            var sut = new ContestEvaluation(electionResultsFile, providedTipsFile);

            //act
            var result = sut.CountScore(5, 3);

            //verify
            string expectedTipperNameOne = "Lubo";

            Assert.IsTrue(result.Any(x => x.TipperName.Equals(expectedTipperNameOne)),
                          $"Evaluated tips must contain a tip with TipperName {expectedTipperNameOne}.");
            string expectedTipperNameTwo = "Miso";

            Assert.IsTrue(result.Any(x => x.TipperName.Equals(expectedTipperNameTwo)),
                          $"Evaluated tips must contain a tip with TipperName {expectedTipperNameTwo}.");
        }
Beispiel #7
0
        public void Count_RealResults_ForParliamentElections2020()
        {
            //prepare
            var realElectionResultsFile = FilePathProvider.ProvideFullPathToFile("ParliamentElections2020Results.json", @"Source\PresidentElection\InputData");
            var realTipsFile            = FilePathProvider.ProvideFullPathToFile("ParliamentElections2020Tips.json", @"Source\PresidentElection\InputData");
            var sut = new ContestEvaluation(realElectionResultsFile, realTipsFile);

            //act
            var result = sut.CountScore(1, 6).OrderBy(x => x.Score).ToList();
            int i      = 0;

            Console.WriteLine("{0} {1,6} {2,7}", "Place", "Name", "Score");
            Console.WriteLine("--------------------");
            foreach (var evaluatedTip in result)
            {
                Console.WriteLine($"{++i,3}. {evaluatedTip.TipperName,7} {evaluatedTip.Score,7}");
            }
        }