public void TimerLockService_GetAll_CallsRepositoryAll() { #region Arrange #endregion #region Act var timerLocks = _timerLockService.All(); #endregion #region Assert _mockTimerLockRepository.Verify(x => x.All(), Times.Once); Assert.AreEqual(_timerLocks.Count, timerLocks.Count()); #endregion }
public override bool CanExecute(Task task, Guid?serverInstanceId) { if (serverInstanceId != null && task.Pin != null) { var timerLocks = _timerLockService.All().ToList(); if (timerLocks.Any()) { if (timerLocks.Any(x => x.LockedInstance != serverInstanceId.Value && x.LockedPin == task.Pin.Value)) { // Only the locked server instance id can process tasks for this Pin whilst locked return(false); } if (timerLocks.Any(x => x.LockedInstance == serverInstanceId.Value && x.LockedPin == task.Pin.Value && x.TaskId != task.Id)) { // Once locked the server instance id cannot complete any other the request for that Pin until the locked Task is completed return(false); } } } return(DateTime.Compare(DateTime.Now, task.NextScheduledDate.GetValueOrDefault()) > 0); }