public async Task BatchProcessing_when_all_fail_within_timeout_boundaries() { // Arrange var batchTimeoutInMilliseconds = 1000; var tasks = TasksFactory.CreateFailedTasks(500, 500, 500); var counter = new Counter(); // Act await EnumerableExt.BatchProcessing( self : tasks, batchTimeoutInMilliseconds : batchTimeoutInMilliseconds, onSuccess : counter.CountSucceeded, onFail : counter.CountFailed, nextBatch : counter.CountNextBatches); // Assert counter.Succeeded.Should().Be(0); counter.Failed.Should().Be(tasks.Count); counter.NextBatch.Should().Be(0); }
public async Task BatchProcessing_execution_time_of_one_task_bigger_than_timeout() { // Arrange var batchTimeoutInMilliseconds = 1000; var tasks = TasksFactory.CreateTasks(500, 1200, 500); var counter = new Counter(); // Act await EnumerableExt.BatchProcessing( self : tasks, batchTimeoutInMilliseconds : batchTimeoutInMilliseconds, onSuccess : counter.CountSucceeded, onFail : counter.CountFailed, nextBatch : counter.CountNextBatches); // Assert counter.Succeeded.Should().Be(5); counter.Failed.Should().Be(0); counter.NextBatch.Should().Be(tasks.Count - 1); }