Converts all 73 test source files from file-scoped (namespace X;) to
block-scoped (namespace X { ... }) declarations, re-indenting their
contents accordingly. Matches the existing convention already used in
several production files (e.g. Musify.Infrastructure.Configuration,
Musify.Application.Contracts).
Mechanical change only, done with a script, verified with a full
rebuild (0 warnings, 0 errors) and test run (257/257 passing).
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using ErrorOr;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Application.YouTube;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Musify.Application.Tests.YouTube
|
|
{
|
|
public sealed class SearchYouTubeTracksQueryHandlerTests
|
|
{
|
|
private readonly IYouTubeMusicService youTubeMusicService = Substitute.For<IYouTubeMusicService>();
|
|
|
|
private SearchYouTubeTracksQueryHandler CreateHandler() => new(youTubeMusicService);
|
|
|
|
[Fact]
|
|
public async Task Handle_EmptyQuery_ReturnsValidationErrorWithoutCallingTheService()
|
|
{
|
|
var result = await CreateHandler().Handle(new SearchYouTubeTracksQuery(string.Empty, string.Empty), TestContext.Current.CancellationToken);
|
|
|
|
Assert.Equal(ErrorType.Validation, result.FirstError.Type);
|
|
await youTubeMusicService.DidNotReceiveWithAnyArgs()
|
|
.SearchSongsAsync(default!, default!, TestContext.Current.CancellationToken);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Handle_NonEmptyQuery_DelegatesToTheService()
|
|
{
|
|
var expected = new YouTubeSearchResult([], "next-token");
|
|
youTubeMusicService.SearchSongsAsync("query", "token", Arg.Any<CancellationToken>()).Returns(expected);
|
|
|
|
var result = await CreateHandler().Handle(new SearchYouTubeTracksQuery("query", "token"), TestContext.Current.CancellationToken);
|
|
|
|
Assert.False(result.IsError);
|
|
Assert.Same(expected, result.Value);
|
|
}
|
|
}
|
|
}
|