public void PunchClock_ClockIn() { using (var transaction = _db.Connection.BeginTransaction()) { var context = _db.CreateContext(transaction); var tsService = new EFTimeSheetService(context, _mapper, new NullLogger <EFTimeSheetService>()); var createDto = new TimeEntryCreateDto { MemberId = context.Members.FirstOrDefault().Id, PositionId = context.Positions.FirstOrDefault().Id, StartTime = DateTime.Now }; var existingMemberTimeEntryId = context.TimeEntries.FirstOrDefault(t => t.MemberId == createDto.MemberId && t.EndTime == null).Id; List <int> existingMemberTimeEntryIds = new List <int>(); existingMemberTimeEntryIds.Add(existingMemberTimeEntryId); var deleteMemberEntry = tsService.DeleteEntries(existingMemberTimeEntryIds).Result; var result = tsService.PunchClock(createDto).Result; Assert.True(result.Successful); Assert.True(context.TimeEntries.OrderBy(t => t.Id).LastOrDefault().EndTime == null); } }
public void PunchClock_InvalidEntry() { using (var transaction = _db.Connection.BeginTransaction()) { var context = _db.CreateContext(transaction); var tsService = new EFTimeSheetService(context, _mapper, new NullLogger <EFTimeSheetService>()); var clockInDto = new TimeEntryCreateDto { MemberId = context.Members.FirstOrDefault().Id, PositionId = context.Positions.FirstOrDefault().Id, StartTime = DateTime.Now, EndTime = DateTime.Now, }; var clockOutResult = tsService.PunchClock(clockInDto).Result; Assert.False(clockOutResult.Successful); } }