mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05:00 
			
		
		
		
	Merge branch 'sqlite' of github.com:AnonymusRaccoon/Kyoo into sqlite
This commit is contained in:
		
						commit
						4a5a3775f0
					
				
							
								
								
									
										2
									
								
								.github/workflows/analysis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/analysis.yml
									
									
									
									
										vendored
									
									
								
							@ -41,7 +41,6 @@ jobs:
 | 
			
		||||
        with:
 | 
			
		||||
          commit: ${{env.COMMIT_SHA}}
 | 
			
		||||
          workflow: tests.yml
 | 
			
		||||
          name: coverage.xml
 | 
			
		||||
          github_token: ${{secrets.GITHUB_TOKEN}}
 | 
			
		||||
      - name: Build and analyze
 | 
			
		||||
        env:
 | 
			
		||||
@ -49,6 +48,7 @@ jobs:
 | 
			
		||||
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
 | 
			
		||||
        shell: bash
 | 
			
		||||
        run: |
 | 
			
		||||
          find . -name 'coverage.opencover.xml'
 | 
			
		||||
          dotnet build-server shutdown
 | 
			
		||||
 | 
			
		||||
          ./.sonar/scanner/dotnet-sonarscanner begin \
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,4 @@
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using JetBrains.Annotations;
 | 
			
		||||
using Xunit;
 | 
			
		||||
@ -19,7 +20,7 @@ namespace Kyoo.Tests
 | 
			
		||||
		[AssertionMethod]
 | 
			
		||||
		public static void DeepEqual<T>(T expected, T value)
 | 
			
		||||
		{
 | 
			
		||||
			foreach (PropertyInfo property in typeof(T).GetProperties())
 | 
			
		||||
			foreach (PropertyInfo property in typeof(T).GetProperties(BindingFlags.Instance))
 | 
			
		||||
				Assert.Equal(property.GetValue(expected), property.GetValue(value));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								Kyoo.Tests/Library/SpecificTests/LibraryItemTest.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								Kyoo.Tests/Library/SpecificTests/LibraryItemTest.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Kyoo.Controllers;
 | 
			
		||||
using Kyoo.Models;
 | 
			
		||||
using Xunit;
 | 
			
		||||
using Xunit.Abstractions;
 | 
			
		||||
 | 
			
		||||
namespace Kyoo.Tests.Library
 | 
			
		||||
{
 | 
			
		||||
	namespace SqLite
 | 
			
		||||
	{
 | 
			
		||||
		public class LibraryItemTest : ALibraryItemTest
 | 
			
		||||
		{
 | 
			
		||||
			public LibraryItemTest(ITestOutputHelper output)
 | 
			
		||||
				: base(new RepositoryActivator(output)) { }
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	namespace PostgreSQL
 | 
			
		||||
	{
 | 
			
		||||
		[Collection(nameof(Postgresql))]
 | 
			
		||||
		public class LibraryItemTest : ALibraryItemTest
 | 
			
		||||
		{
 | 
			
		||||
			public LibraryItemTest(PostgresFixture postgres, ITestOutputHelper output)
 | 
			
		||||
				: base(new RepositoryActivator(output, postgres)) { }
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public abstract class ALibraryItemTest
 | 
			
		||||
	{
 | 
			
		||||
		private readonly ILibraryItemRepository _repository;
 | 
			
		||||
		
 | 
			
		||||
		public ALibraryItemTest(RepositoryActivator repositories)
 | 
			
		||||
		{
 | 
			
		||||
			_repository = repositories.LibraryManager.LibraryItemRepository;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public async Task CountTest()
 | 
			
		||||
		{
 | 
			
		||||
			Assert.Equal(2, await _repository.GetCount());
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public async Task GetShowTests()
 | 
			
		||||
		{
 | 
			
		||||
			LibraryItem expected = new(TestSample.Get<Show>());
 | 
			
		||||
			LibraryItem actual = await _repository.Get(1);
 | 
			
		||||
			KAssert.DeepEqual(expected, actual);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[Fact]
 | 
			
		||||
		public async Task GetCollectionTests()
 | 
			
		||||
		{
 | 
			
		||||
			LibraryItem expected = new(TestSample.Get<Show>());
 | 
			
		||||
			LibraryItem actual = await _repository.Get(-1);
 | 
			
		||||
			KAssert.DeepEqual(expected, actual);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -17,6 +17,17 @@ namespace Kyoo.Tests
 | 
			
		||||
		
 | 
			
		||||
		private static readonly Dictionary<Type, Func<object>> Samples = new()
 | 
			
		||||
		{
 | 
			
		||||
			{
 | 
			
		||||
				typeof(Collection),
 | 
			
		||||
				() => new Collection
 | 
			
		||||
				{
 | 
			
		||||
					ID = 1,
 | 
			
		||||
					Slug = "collection",
 | 
			
		||||
					Name = "Collection",
 | 
			
		||||
					Overview = "A nice collection for tests",
 | 
			
		||||
					Poster = "Poster"
 | 
			
		||||
				}
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				typeof(Show),
 | 
			
		||||
				() => new Show
 | 
			
		||||
@ -101,6 +112,10 @@ namespace Kyoo.Tests
 | 
			
		||||
 | 
			
		||||
		public static void FillDatabase(DatabaseContext context)
 | 
			
		||||
		{
 | 
			
		||||
			Collection collection = Get<Collection>();
 | 
			
		||||
			collection.ID = 0;
 | 
			
		||||
			context.Collections.Add(collection);
 | 
			
		||||
			
 | 
			
		||||
			Show show = Get<Show>();
 | 
			
		||||
			show.ID = 0;
 | 
			
		||||
			context.Shows.Add(show);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user