예제 #1
0
        public void GetExpenses()
        {
            // Arrange
            MonthSummary summary = BuildSummary();

            // Act
            var statements = summary.GetExpenses();

            // Assert
            Assert.Equal(4, statements.Count);
            Assert.Equal(621.10m, statements.Where(x => x.Category.Name == IncomeCategoryName).Sum(x => x.Amount.Value));
            Assert.Equal(500.20m, statements.Where(x => x.Category.Name == IncomePaidCategoryName).Sum(x => x.Amount.Value));
        }
예제 #2
0
 private IReadOnlyList <ExpenseDto> FormatExpenses() => summary
 .GetExpenses()
 .GroupBy(x => x.Category)
 .Select(x => new ExpenseDto(x.Key, x.Sum(values => values.Amount.Value)))
 .ToList();