示例#1
0
        public void TimesheetsToDTOs_Should_ReturnValidDTOCollection()
        {
            var mockTimesheet1       = CreateMockTimesheet();
            var mockTimesheet2       = CreateMockTimesheet();
            var timesheetsCollection = new List <Timesheet> {
                mockTimesheet1, mockTimesheet2
            };

            var sut = ModelToDto.TimesheetsToDtos(timesheetsCollection);

            Assert.AreEqual(sut.Count(), 2);
        }
        public async Task <IEnumerable <TimesheetDTO> > GetTimesheet([FromQuery] string state)
        {
            var currentUser = await _userManager.FindByNameAsync(User?.Identity?.Name);

            List <Timesheet> timesheets;

            if (!string.IsNullOrEmpty(state) && state.Equals(States.Closed))
            {
                timesheets = _context.Timesheet.Include(timesheet => timesheet.Rows).Where(timesheet => timesheet.UserId.Equals(currentUser.Id) && timesheet.State.Equals(States.Closed)).ToList();
            }
            else
            {
                timesheets = _context.Timesheet.Include(timesheet => timesheet.Rows).Where(timesheet => timesheet.UserId.Equals(currentUser.Id)).ToList();
            }


            var dtos = ModelToDto.TimesheetsToDtos(timesheets);

            return(dtos);
        }
示例#3
0
        public void TimesheetsToDTOs_WhenPassedEmptyArgument_Should_ReturnEmptyDTOCollection()
        {
            var sut = ModelToDto.TimesheetsToDtos(new List <Timesheet>());

            Assert.AreEqual(sut.Count(), 0);
        }