Пример #1
0
            private Task <ListModel <AT1ReportItemDTO> > TapWithAgeValues(ListModel <AT1ReportItemDTO> bareResults)
            {
                var currentDate = _datetimeProvider.Now;

                bareResults.Items.ForEach(item =>
                {
                    if (item.Birthdate == null)
                    {
                        return;
                    }
                    var ageTuple              = _dateTimeCalculationsDomainService.CalculateDifference(item.Birthdate.Value, currentDate);
                    item.AgeInYears           = ageTuple.Years;
                    item.AgeInMonthsOverYears = ageTuple.Months;
                    item.AgeInDaysOverMonths  = ageTuple.Days;
                });
                return(Task.FromResult(bareResults));
            }
Пример #2
0
        public void CalculateDifference_should_work_for_cases_where_dates_are_on_the_very_same_month()
        {
            // Arrange
            var pastDate    = new DateTime(2016, 1, 10);
            var currentDate = new DateTime(2016, 1, 20);
            var expectedAge = new AgeDescriptor(0, 0, 10);

            // Act
            var actualAge = _calculationsService.CalculateDifference(pastDate, currentDate);

            // Assert
            actualAge.Should().Be(expectedAge);
        }