Beispiel #1
0
        public async Task CollectAndShowAsync(IContainer container, bool isIntegrationTest)
        {
            var errorsAndInfos   = new ErrorsAndInfos();
            var secretRepository = container.Resolve <ISecretRepository>();

            CalculationLogger.ClearLogs();

            var allPostings = await PostingCollector.CollectPostingsAsync(container, isIntegrationTest);

            var postingClassificationsSecret = await secretRepository.GetAsync(new PostingClassificationsSecret(), errorsAndInfos);

            if (errorsAndInfos.AnyErrors())
            {
                await DataPresenter.WriteErrorsAsync(errorsAndInfos);

                return;
            }

            var postingClassifications = postingClassificationsSecret.Cast <IPostingClassification>().ToList();

            await SummaryCalculator.CalculateAndShowSummaryAsync(allPostings, postingClassifications);

            await AverageCalculator.CalculateAndShowAverageAsync(allPostings, postingClassifications);

            await MonthlyDeltaCalculator.CalculateAndShowMonthlyDeltaAsync(allPostings, postingClassifications);

            await ClassifiedPostingsCalculator.CalculateAndShowClassifiedPostingsAsync(allPostings, postingClassifications, DateTime.Now.AddYears(-1), 70);

            CalculationLogger.Flush();
        }
Beispiel #2
0
        public async Task CanCalculateAverage()
        {
            await Sut.CalculateAndShowAverageAsync(new List <IPosting> {
                TestData.PostingC2, TestData.PostingD2, TestData.PostingC3, TestData.PostingD3
            },
                                                   new List <IPostingClassification> {
                TestData.PostingClassificationC1, TestData.PostingClassificationC2, TestData.PostingClassificationD1, TestData.PostingClassificationD2
            });

            var items = FakeDataPresenter.ClassificationAverages;

            VerifyResult(items[0], "-", "1510", 10, 0);
            VerifyResult(items[1], "-", "1989", 20, 0);
            VerifyResult(items[2], "+", "2407", 5, 0);
            VerifyResult(items[3], "+", "4711", 15, 0);
        }