Enhance GridPlanner and GenerateGridDialog for improved slot management and user experience
Refactored the GridPlanner class to optimize slot management during grid generation, ensuring more efficient handling of slots. Updated the GenerateGridDialog component to improve its layout and usability, enhancing the overall user experience when interacting with slot lists. These changes contribute to better functionality and accessibility in grid management.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using TeleWave.Infrastructure.Media;
|
||||
using Xunit;
|
||||
|
||||
namespace TeleWave.Application.Tests.Media;
|
||||
|
||||
/// <summary>
|
||||
/// Сигнальная очередь конвейера и предел параллельности. Мелочь, но на первой держится реакция
|
||||
/// обработчика на новый файл, а на втором — оценка «сколько ещё ждать».
|
||||
/// </summary>
|
||||
public class MediaQueueTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Queue_WakesUpOnce_ForAWholeBurstOfSignals()
|
||||
{
|
||||
var queue = new MediaProcessingQueue();
|
||||
|
||||
queue.Enqueue(Guid.NewGuid());
|
||||
queue.Enqueue(Guid.NewGuid());
|
||||
queue.Enqueue(Guid.NewGuid());
|
||||
|
||||
// Первый вызов возвращается сразу и дренирует накопленное: работу обработчик всё равно
|
||||
// берёт из БД пачкой, и три сигнала не должны означать три круга.
|
||||
await queue.WaitAsync(CancellationToken.None);
|
||||
|
||||
using var cts = new CancellationTokenSource();
|
||||
await cts.CancelAsync();
|
||||
// Очередь пуста — следующий вызов ждёт нового сигнала, а не возвращается снова.
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(async () =>
|
||||
await queue.WaitAsync(cts.Token)
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(4, 4)]
|
||||
[InlineData(0, 1)]
|
||||
[InlineData(-2, 1)]
|
||||
public void Limits_NeverReportLessThanOneTranscode(int configured, int expected)
|
||||
{
|
||||
var limits = new MediaProcessingLimits(
|
||||
Options.Create(new MediaOptions { MaxParallelTranscodes = configured })
|
||||
);
|
||||
|
||||
// Ноль и отрицательное в настройках — не повод делить оценку очереди на ноль.
|
||||
Assert.Equal(expected, limits.MaxParallelTranscodes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user