public void CanSumMoneyWhichHasLeftTheRegisterWhenDataIsNotSortedByPublicationSet()
        {
            // Arrange
            var data = new Dictionary <string, Dictionary <string, PublicationSetTotal> >()
            {
                {
                    "smith_dave", new Dictionary <string, PublicationSetTotal>()
                    {
                        { "150702", new PublicationSetTotal("150702", 5m) },
                        { "150402", new PublicationSetTotal("150402", 2m) },
                        { "150502", new PublicationSetTotal("150502", 2m) },
                        { "150602", new PublicationSetTotal("150602", 1m) },
                        { "150802", new PublicationSetTotal("150802", 1m) },
                    }
                },
            };

            var query = new AmountByPublicationSetForEachMpProjectionExplorer(data);

            // Act
            var result = query.TopHistoricalEarners(1);

            // Assert
            Assert.AreEqual(5m, result.First().Amount);
        }
Exemple #2
0
        public async Task MakeJsonOutput()
        {
            var summaries = new List <MpInterestSummary>();

            var dataExplorer = new AmountByPublicationSetForEachMpProjectionExplorer(await this.dataSource.GetProjectionData($"{this.localDataPath}\\{this.outputSummaryFileName}"));

            foreach (var detail in dataExplorer.DetailsByMp())
            {
                this.logger.LogInformation($"Creating file for {detail.Name}");

                var filePath = $"{this.outputJsonPath}\\{detail.Identifier}.json";

                var fileContent = JsonSerializer.Serialize(detail, new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    WriteIndented        = true,
                });

                summaries.Add(new MpInterestSummary(detail.Identifier, detail.Name, detail.CurrentValue, detail.HistoricalValue, detail.LatestEntryDate));

                await this.OutputFile(filePath, fileContent);
            }

            await this.OutputFile($"{this.outputJsonPath}\\summary.json", JsonSerializer.Serialize(summaries.OrderByDescending(x => x.HistoricalValue).ToArray(), new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                WriteIndented        = true,
            }));
        }
Exemple #3
0
        public async Task <string> ShowReport()
        {
            var dataExplorer = new AmountByPublicationSetForEachMpProjectionExplorer(await this.dataSource.GetProjectionData($"{this.localDataPath}\\{this.outputSummaryFileName}"));

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Financial interests since 14/12/2015");

            stringBuilder.AppendLine("Entries with high value financial transactions");

            stringBuilder.AppendLine(string.Format("|{0,20}|{1,20}|{2,20}", "Member's name", "Approximate value", "Most recent entry"));

            stringBuilder.Append(this.ShowEarners(() => dataExplorer.TopCurrentEarners(20)));

            stringBuilder.AppendLine();

            stringBuilder.AppendLine("Cumulative financial interests since 14/12/2015");

            stringBuilder.AppendLine("Entries with high value financial transactions");

            stringBuilder.AppendLine(string.Format("|{0,20}|{1,20}|{2,20}", "Member's name", "Approximate value", "Most recent entry"));

            stringBuilder.Append(this.ShowEarners(() => dataExplorer.TopEarnersOverall(20)));

            return(stringBuilder.ToString());
        }