- ScheduleController GET/POST/PUT items now assert flat ScheduleItemResponseModel shapes - LanguagesControllerTests (route + VM->DTO mapping) - ChannelController tests for music-video-credits-templates + stream-selectors literal routes - FillerPreset controller/handler tests for FillerKind field + ?fillerKind= filter Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Reflection;
|
|
using ErsatzTV.Application.MediaItems;
|
|
using ErsatzTV.Controllers.Api;
|
|
using ErsatzTV.Core.Api.MediaItems;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc.Routing;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using Shouldly;
|
|
|
|
namespace ErsatzTV.Tests.Controllers;
|
|
|
|
[TestFixture]
|
|
public class LanguagesControllerTests
|
|
{
|
|
private LanguagesController _controller = null!;
|
|
private IMediator _mediator = null!;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
_mediator = Substitute.For<IMediator>();
|
|
_controller = new LanguagesController(_mediator);
|
|
}
|
|
|
|
[Test]
|
|
public void Controller_Should_Expose_Idiomatic_Rest_Route()
|
|
{
|
|
MethodInfo action = typeof(LanguagesController).GetMethod(nameof(LanguagesController.GetLanguages))!;
|
|
HttpMethodAttribute attribute = action.GetCustomAttributes<HttpMethodAttribute>(inherit: true).Single();
|
|
attribute.HttpMethods.ShouldContain("GET");
|
|
attribute.Template.ShouldBe("/api/languages");
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetLanguages_Should_Map_Vm_To_ResponseModel()
|
|
{
|
|
List<LanguageCodeViewModel> vms =
|
|
[
|
|
new LanguageCodeViewModel("eng", "English"),
|
|
new LanguageCodeViewModel("fra", "French")
|
|
];
|
|
_mediator.Send(Arg.Any<GetAllLanguageCodes>(), Arg.Any<CancellationToken>())
|
|
.Returns(vms);
|
|
|
|
List<LanguageCodeResponseModel> result = await _controller.GetLanguages(CancellationToken.None);
|
|
|
|
result.ShouldBe(
|
|
[
|
|
new LanguageCodeResponseModel("eng", "English"),
|
|
new LanguageCodeResponseModel("fra", "French")
|
|
]);
|
|
}
|
|
}
|