public Task ExecuteAsync(FailsNTimesBeforeSucceeding payload, ITaskExecutionContext executionContext) { int currentFailCount; if (!mFailCount.TryGetValue(payload.Id, out currentFailCount)) { currentFailCount = 0; } currentFailCount++; mFailCount.AddOrUpdate(payload.Id, addValueFactory: (id) => currentFailCount, updateValueFactory: (id, old) => currentFailCount); TestExecutorEventBus <FailsNTimesBeforeSucceeding> .Instance .NotifyExecutorCompleted(); if (currentFailCount <= payload.FailuresBeforeSuccess) { throw new InvalidOperationException($"Sample invalid operation during {nameof( FailsNTimesBeforeSucceeding )}"); } else { executionContext.NotifyTaskCompleted(); } return(Task.CompletedTask); }
public Task ExecuteAsync(SuccessfulTaskPayload payload, ITaskExecutionContext executionContext) { executionContext.NotifyTaskCompleted(); return(Task.CompletedTask); }