From d2f774e32d9013987d6aebd132ae97fa8be59c73 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 21 Jun 2021 23:44:23 +0200 Subject: [PATCH] Cleaning namespaces and adding episodes tests --- Kyoo.Tests/Kyoo.Tests.csproj | 1 - .../Library/SpecificTests/EpisodeTest.cs | 32 +++++++++++++++++++ .../Library/SpecificTests/SanityTests.cs | 3 +- .../Library/SpecificTests/SeasonTests.cs | 30 +++++++++-------- Kyoo.Tests/Library/SpecificTests/ShowTests.cs | 32 +++++++++++-------- Kyoo.Tests/Library/TestContext.cs | 6 ++-- 6 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 Kyoo.Tests/Library/SpecificTests/EpisodeTest.cs diff --git a/Kyoo.Tests/Kyoo.Tests.csproj b/Kyoo.Tests/Kyoo.Tests.csproj index 9d1e8311..265ccb98 100644 --- a/Kyoo.Tests/Kyoo.Tests.csproj +++ b/Kyoo.Tests/Kyoo.Tests.csproj @@ -16,7 +16,6 @@ - runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Kyoo.Tests/Library/SpecificTests/EpisodeTest.cs b/Kyoo.Tests/Library/SpecificTests/EpisodeTest.cs new file mode 100644 index 00000000..a7b3d743 --- /dev/null +++ b/Kyoo.Tests/Library/SpecificTests/EpisodeTest.cs @@ -0,0 +1,32 @@ +using Kyoo.Models; +using Xunit; + +namespace Kyoo.Tests.Library +{ + namespace SqLite + { + public class EpisodeTests : AEpisodeTests + { + public EpisodeTests() + : base(new RepositoryActivator()) { } + } + } + + + namespace PostgreSQL + { + [Collection(nameof(Postgresql))] + public class EpisodeTests : AEpisodeTests + { + public EpisodeTests(PostgresFixture postgres) + : base(new RepositoryActivator(postgres)) { } + } + } + + public abstract class AEpisodeTests : RepositoryTests + { + protected AEpisodeTests(RepositoryActivator repositories) + : base(repositories) + { } + } +} \ No newline at end of file diff --git a/Kyoo.Tests/Library/SpecificTests/SanityTests.cs b/Kyoo.Tests/Library/SpecificTests/SanityTests.cs index 7d7794fa..098c4677 100644 --- a/Kyoo.Tests/Library/SpecificTests/SanityTests.cs +++ b/Kyoo.Tests/Library/SpecificTests/SanityTests.cs @@ -1,11 +1,10 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading.Tasks; using Kyoo.Models; using Xunit; -namespace Kyoo.Tests.SpecificTests +namespace Kyoo.Tests.Library { public class GlobalTests : IDisposable, IAsyncDisposable { diff --git a/Kyoo.Tests/Library/SpecificTests/SeasonTests.cs b/Kyoo.Tests/Library/SpecificTests/SeasonTests.cs index 7f81bc3f..0c912d07 100644 --- a/Kyoo.Tests/Library/SpecificTests/SeasonTests.cs +++ b/Kyoo.Tests/Library/SpecificTests/SeasonTests.cs @@ -2,30 +2,34 @@ using System.Threading.Tasks; using Kyoo.Controllers; using Kyoo.Models; using Xunit; -using Xunit.Extensions.Ordering; -namespace Kyoo.Tests.SpecificTests +namespace Kyoo.Tests.Library { - public class SqLiteSeasonTests : SeasonTests + namespace SqLite { - public SqLiteSeasonTests() - : base(new RepositoryActivator()) - { } + public class SeasonTests : ASeasonTests + { + public SeasonTests() + : base(new RepositoryActivator()) { } + } } - public class PostgresSeasonTests : SeasonTests, IAssemblyFixture + namespace PostgreSQL { - public PostgresSeasonTests(PostgresFixture postgres) - : base(new RepositoryActivator(postgres)) - { } + [Collection(nameof(Postgresql))] + public class SeasonTests : ASeasonTests + { + public SeasonTests(PostgresFixture postgres) + : base(new RepositoryActivator(postgres)) { } + } } - - public abstract class SeasonTests : RepositoryTests + + public abstract class ASeasonTests : RepositoryTests { private readonly ISeasonRepository _repository; - protected SeasonTests(RepositoryActivator repositories) + protected ASeasonTests(RepositoryActivator repositories) : base(repositories) { _repository = Repositories.LibraryManager.SeasonRepository; diff --git a/Kyoo.Tests/Library/SpecificTests/ShowTests.cs b/Kyoo.Tests/Library/SpecificTests/ShowTests.cs index d16f13e9..facb8e81 100644 --- a/Kyoo.Tests/Library/SpecificTests/ShowTests.cs +++ b/Kyoo.Tests/Library/SpecificTests/ShowTests.cs @@ -6,29 +6,33 @@ using Kyoo.Controllers; using Kyoo.Models; using Microsoft.EntityFrameworkCore; using Xunit; -using Xunit.Extensions.Ordering; -namespace Kyoo.Tests.SpecificTests +namespace Kyoo.Tests.Library { - public class SqLiteShowTests : ShowTests + namespace SqLite { - public SqLiteShowTests() - : base(new RepositoryActivator()) - { } + public class ShowTests : AShowTests + { + public ShowTests() + : base(new RepositoryActivator()) { } + } } - - public class PostgresShowTests : ShowTests, IAssemblyFixture + + namespace PostgreSQL { - public PostgresShowTests(PostgresFixture postgres) - : base(new RepositoryActivator(postgres)) - { } + [Collection(nameof(Postgresql))] + public class ShowTests : AShowTests + { + public ShowTests(PostgresFixture postgres) + : base(new RepositoryActivator(postgres)) { } + } } - - public abstract class ShowTests : RepositoryTests + + public abstract class AShowTests : RepositoryTests { private readonly IShowRepository _repository; - protected ShowTests(RepositoryActivator repositories) + protected AShowTests(RepositoryActivator repositories) : base(repositories) { _repository = Repositories.LibraryManager.ShowRepository; diff --git a/Kyoo.Tests/Library/TestContext.cs b/Kyoo.Tests/Library/TestContext.cs index 82406454..61332a8d 100644 --- a/Kyoo.Tests/Library/TestContext.cs +++ b/Kyoo.Tests/Library/TestContext.cs @@ -8,8 +8,6 @@ using Microsoft.Extensions.Logging; using Npgsql; using Xunit; -[assembly: TestFramework("Xunit.Extensions.Ordering.TestFramework", "Xunit.Extensions.Ordering")] - namespace Kyoo.Tests { public sealed class SqLiteTestContext : TestContext @@ -56,6 +54,10 @@ namespace Kyoo.Tests return new SqLiteContext(_context); } } + + [CollectionDefinition(nameof(Postgresql))] + public class PostgresCollection : ICollectionFixture + {} public sealed class PostgresFixture : IDisposable {