Exemplo n.º 1
0
        public void Read_ReturnsCandidateNameElectionGainPairsObject()
        {
            //prepare
            var inputFileNameFullPath = FilePathProvider.ProvideFullPathToFile("TestResults.json", inputDataDirectoryName);
            var sut = new ElectionResultsReader(inputFileNameFullPath);

            //act
            CandidateNameElectionGainPairs candidateNameElectionGainPairs = sut.Read();

            //assert
            Assert.That(candidateNameElectionGainPairs, Is.TypeOf <CandidateNameElectionGainPairs>());
        }
Exemplo n.º 2
0
        public void ElectionResultsReaderObject_InitializedCorrectly()
        {
            //prepare
            var inputFileNameFullPath = FilePathProvider.ProvideFullPathToFile("TestResults.json", inputDataDirectoryName);

            //act
            var sut = new ElectionResultsReader(inputFileNameFullPath);

            Console.WriteLine($"Full file name: {sut.InputFileName}");

            //assert
            Assert.That(sut.InputFileName, Is.EqualTo(inputFileNameFullPath));
        }
        public EvaluatedTips CountScore(int bonusForCorrectPlace, int countOfTippedPlaces)
        {
            var providedTips        = new ProvidedTipsReader(ProvidedTipsFileName).Read();
            int countOfProvidedTips = providedTips.Count;
            var evaluatedTips       = new EvaluatedTips();
            CandidateNameElectionGainPairs electionResults = new ElectionResultsReader(ElectionResultsFileName).Read();
            ScoreCounter scoreCounter = new ScoreCounter(electionResults, bonusForCorrectPlace);

            for (int i = 0; i < countOfProvidedTips; i++)
            {
                double score = scoreCounter.Count(providedTips[i], countOfTippedPlaces);
                evaluatedTips.Add(new EvaluatedTip(providedTips[i].TipperName, score));
            }
            return(evaluatedTips);
        }
Exemplo n.º 4
0
        public void Read_ReadOutValuesFitWithValuesInFile()
        {
            //prepare
            var inputFileNameFullPath = FilePathProvider.ProvideFullPathToFile("TestResults.json", inputDataDirectoryName);
            var sut = new ElectionResultsReader(inputFileNameFullPath);

            //act
            CandidateNameElectionGainPairs candidateNameElectionGainPairs = sut.Read();

            //assert
            Assert.That(candidateNameElectionGainPairs[0].CandidateName, Is.EqualTo("TestCandidate1"));
            Assert.That(candidateNameElectionGainPairs[1].CandidateName, Is.EqualTo("TestCandidate2"));
            Assert.That(candidateNameElectionGainPairs[2].CandidateName, Is.EqualTo("TestCandidate3"));
            Assert.That(candidateNameElectionGainPairs[0].ElectionGainInPercent, Is.EqualTo(40));
            Assert.That(candidateNameElectionGainPairs[1].ElectionGainInPercent, Is.EqualTo(30));
            Assert.That(candidateNameElectionGainPairs[2].ElectionGainInPercent, Is.EqualTo(20));
        }
Exemplo n.º 5
0
        public void Read_ReturnedThreeCandidateNameElectionGainPairs()
        {
            //prepare
            var inputFileNameFullPath = FilePathProvider.ProvideFullPathToFile("TestResults.json", inputDataDirectoryName);
            var sut = new ElectionResultsReader(inputFileNameFullPath);

            //act
            CandidateNameElectionGainPairs candidateNameElectionGainPairs = sut.Read();

            foreach (var candidateNameElectionGainPair in candidateNameElectionGainPairs)
            {
                Console.Error.WriteLine($"candidate name: {candidateNameElectionGainPair.CandidateName}");
                Console.Error.WriteLine($"result in percent : {candidateNameElectionGainPair.ElectionGainInPercent}");
            }

            //assert
            Assert.That(candidateNameElectionGainPairs.Count, Is.EqualTo(3));
        }