Example #1
0
        public void set_properties_from_file()
        {
            var electionStatistics = FileNameParser.BuildElectionStatistics("FINAL_DSPR_1561818562.csv", new ElectionResultsData());

            electionStatistics.Location.Should().Be("DSPR");
            electionStatistics.Id.Should().StartWith($"{DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks:D19}".Substring(0, 10));
            electionStatistics.FileTimestamp.Should().Be(1561818562);
            electionStatistics.StatisticsJson.Should().NotBeNullOrEmpty();
            electionStatistics.Type.Should().Be("FINAL");
        }
Example #2
0
        public void set_properties_from_file()
        {
            var electionStatistics = FileNameParser.BuildElectionStatistics("FINAL_DSPR_1561818562.csv", new ElectionResultsData());

            electionStatistics.Location.Should().Be("DSPR");
            electionStatistics.Id.Should().Be("FINAL_DSPR_1561818562");
            electionStatistics.FileTimestamp.Should().Be(1561818562);
            electionStatistics.StatisticsJson.Should().NotBeNullOrEmpty();
            electionStatistics.Type.Should().Be("FINAL");
        }
Example #3
0
        public void return_a_file_parsing_result()
        {
            var electionStatistics = FileNameParser.BuildElectionStatistics(new ElectionResultsFile
            {
                FileType      = FileType.Results,
                ResultsSource = "DSPR",
                Timestamp     = 1561818562
            }, new ElectionResultsData());

            electionStatistics.Should().NotBeNull();
        }
Example #4
0
        public async Task ProcessStream(Stream csvStream, ElectionResultsFile file)
        {
            var csvContent = await ReadCsvContent(csvStream);

            var aggregationResult = await _statisticsAggregator.RetrieveElectionData(csvContent, file);

            if (aggregationResult.IsSuccess)
            {
                var electionStatistics = FileNameParser.BuildElectionStatistics(file, aggregationResult.Value);
                Log.LogInformation($"Inserting results from {file.Name} with timestamp {electionStatistics.Timestamp}");
                await _resultsRepository.InsertResults(electionStatistics);
            }
        }
Example #5
0
        public async Task ProcessStream(Stream csvStream, string fileName)
        {
            var csvContent = await ReadCsvContent(csvStream);

            var aggregationResult = await _statisticsAggregator.RetrieveElectionData(csvContent);

            if (aggregationResult.IsSuccess)
            {
                var electionStatistics = FileNameParser.BuildElectionStatistics(fileName, aggregationResult.Value);
                Console.WriteLine($"Uploading file {fileName} with timestamp {electionStatistics.FileTimestamp}");
                await _resultsRepository.InsertResults(electionStatistics);
            }
        }
        public async Task ProcessStream(Stream csvStream, string fileName)
        {
            Config.Candidates = await _electionConfigurationSource.GetListOfCandidates();

            var csvContent = await ReadCsvContent(csvStream);

            var aggregationResult = await _statisticsAggregator.RetrieveElectionData(csvContent);

            if (aggregationResult.IsSuccess)
            {
                var electionStatistics = FileNameParser.BuildElectionStatistics(fileName, aggregationResult.Value);
                await _resultsRepository.InsertResults(electionStatistics);
            }
        }
Example #7
0
        public void set_properties_from_file()
        {
            var electionStatistics = FileNameParser.BuildElectionStatistics(new ElectionResultsFile {
                FileType      = FileType.Results,
                ResultsSource = "DSPR",
                Timestamp     = 1561818562
            }, new ElectionResultsData());

            electionStatistics.Source.Should().Be("DSPR");
            electionStatistics.Id.Should().StartWith($"{DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks:D19}".Substring(0, 10));
            electionStatistics.Timestamp.Should().Be(1561818562);
            electionStatistics.StatisticsJson.Should().NotBeNullOrEmpty();
            electionStatistics.Type.Should().Be(FileType.Results.ConvertEnumToString());
        }
Example #8
0
        public async Task ProcessStream(Stream csvStream, string fileName)
        {
            _logger.LogInformation($"Processing csv with stream of {csvStream.Length} bytes");
            var csvContent = await ReadCsvContent(csvStream);

            var aggregationResult = await _statisticsAggregator.RetrieveElectionData(csvContent);

            if (aggregationResult.IsSuccess)
            {
                var electionStatistics = FileNameParser.BuildElectionStatistics(fileName, aggregationResult.Value);
                _logger.LogInformation($"Inserting results from {fileName} with timestamp {electionStatistics.Timestamp}");

                await _resultsRepository.InsertResults(electionStatistics);
            }
        }
Example #9
0
        public void return_a_file_parsing_result()
        {
            var electionStatistics = FileNameParser.BuildElectionStatistics("FINAL_DSPR_1561818562.csv", new ElectionResultsData());

            electionStatistics.Should().NotBeNull();
        }