Update validation rules in ImportManualInboxCommand and ManualInboxDialog to allow season numbers starting from zero, reflecting the inclusion of special episodes and pilots. Adjust input constraints in the frontend to enhance user experience and ensure consistency with backend validation.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using TeleWave.Application.Media.ManualInbox;
|
||||
using Xunit;
|
||||
|
||||
namespace TeleWave.Application.Tests.Media;
|
||||
|
||||
public class ImportManualInboxValidatorTests
|
||||
{
|
||||
private static ImportManualInboxCommand Command(int? season, int? episode) =>
|
||||
new([new ManualImportItem("Шоу/файл.mkv", season, episode)], Guid.NewGuid());
|
||||
|
||||
[Theory]
|
||||
[InlineData(1, 0)] // пилот идёт как E00 — это норма, а не ошибка ввода
|
||||
[InlineData(0, 1)] // спецвыпуски живут в нулевом сезоне
|
||||
[InlineData(1, 1)]
|
||||
[InlineData(99, 999)]
|
||||
[InlineData(null, null)] // номера не заданы — сервер разберёт имя сам
|
||||
public void AllowsRealWorldNumbers(int? season, int? episode)
|
||||
{
|
||||
Assert.True(new ImportManualInboxCommandValidator().Validate(Command(season, episode)).IsValid);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(-1, 1)]
|
||||
[InlineData(100, 1)]
|
||||
[InlineData(1, -1)]
|
||||
[InlineData(1, 1000)]
|
||||
public void RejectsOutOfRange(int? season, int? episode)
|
||||
{
|
||||
Assert.False(new ImportManualInboxCommandValidator().Validate(Command(season, episode)).IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RejectsEmptyBatchAndMissingShow()
|
||||
{
|
||||
var validator = new ImportManualInboxCommandValidator();
|
||||
|
||||
Assert.False(validator.Validate(new ImportManualInboxCommand([], Guid.NewGuid())).IsValid);
|
||||
Assert.False(
|
||||
validator
|
||||
.Validate(
|
||||
new ImportManualInboxCommand(
|
||||
[new ManualImportItem("файл.mkv", 1, 1)],
|
||||
Guid.Empty
|
||||
)
|
||||
)
|
||||
.IsValid
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user