mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-20 14:00:35 -04:00
79 lines
1.8 KiB
C#
79 lines
1.8 KiB
C#
using System.Threading.Tasks;
|
|
using Kyoo.Controllers;
|
|
using Kyoo.Models;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Kyoo.Tests.Database
|
|
{
|
|
namespace SqLite
|
|
{
|
|
public class SeasonTests : ASeasonTests
|
|
{
|
|
public SeasonTests(ITestOutputHelper output)
|
|
: base(new RepositoryActivator(output)) { }
|
|
}
|
|
}
|
|
|
|
|
|
namespace PostgreSQL
|
|
{
|
|
[Collection(nameof(Postgresql))]
|
|
public class SeasonTests : ASeasonTests
|
|
{
|
|
public SeasonTests(PostgresFixture postgres, ITestOutputHelper output)
|
|
: base(new RepositoryActivator(output, postgres)) { }
|
|
}
|
|
}
|
|
|
|
public abstract class ASeasonTests : RepositoryTests<Season>
|
|
{
|
|
private readonly ISeasonRepository _repository;
|
|
|
|
protected ASeasonTests(RepositoryActivator repositories)
|
|
: base(repositories)
|
|
{
|
|
_repository = Repositories.LibraryManager.SeasonRepository;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SlugEditTest()
|
|
{
|
|
Season season = await _repository.Get(1);
|
|
Assert.Equal("anohana-s1", season.Slug);
|
|
Show show = new()
|
|
{
|
|
ID = season.ShowID,
|
|
Slug = "new-slug"
|
|
};
|
|
await Repositories.LibraryManager.ShowRepository.Edit(show, false);
|
|
season = await _repository.Get(1);
|
|
Assert.Equal("new-slug-s1", season.Slug);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SeasonNumberEditTest()
|
|
{
|
|
Season season = await _repository.Get(1);
|
|
Assert.Equal("anohana-s1", season.Slug);
|
|
await _repository.Edit(new Season
|
|
{
|
|
ID = 1,
|
|
SeasonNumber = 2
|
|
}, false);
|
|
season = await _repository.Get(1);
|
|
Assert.Equal("anohana-s2", season.Slug);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SeasonCreationSlugTest()
|
|
{
|
|
Season season = await _repository.Create(new Season
|
|
{
|
|
ShowID = TestSample.Get<Show>().ID,
|
|
SeasonNumber = 2
|
|
});
|
|
Assert.Equal($"{TestSample.Get<Show>().Slug}-s2", season.Slug);
|
|
}
|
|
}
|
|
} |