From 03af604e94e820b0f3a0ebf013e3ec9569248c34 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 4 Sep 2023 17:34:34 +0200 Subject: [PATCH] Fix tests --- .../Kyoo.Tests/Database/RepositoryActivator.cs | 2 +- .../Database/SpecificTests/ShowTests.cs | 8 +++++++- back/tests/Kyoo.Tests/KAssert.cs | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs index 93604aa1..99fd8dcc 100644 --- a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs +++ b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs @@ -38,7 +38,7 @@ namespace Kyoo.Tests.Database { Context = new PostgresTestContext(postgres, output); - Mock thumbs = new(); + Mock thumbs = new(); CollectionRepository collection = new(_NewContext(), thumbs.Object); StudioRepository studio = new(_NewContext(), thumbs.Object); PeopleRepository people = new(_NewContext(), diff --git a/back/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs b/back/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs index 53bf1d6b..ca537106 100644 --- a/back/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs +++ b/back/tests/Kyoo.Tests/Database/SpecificTests/ShowTests.cs @@ -229,15 +229,21 @@ namespace Kyoo.Tests.Database { x.Show = null; x.People.Roles = null; + x.People.Poster = null; + x.People.Thumbnail = null; + x.People.Logo = null; }); retrieved.Studio!.Shows = null; expected.People.ForEach(x => { x.Show = null; x.People.Roles = null; + x.People.Poster = null; + x.People.Thumbnail = null; + x.People.Logo = null; }); - retrieved.Should().BeEquivalentTo(expected); + KAssert.DeepEqual(retrieved, expected); } [Fact] diff --git a/back/tests/Kyoo.Tests/KAssert.cs b/back/tests/Kyoo.Tests/KAssert.cs index 01a4093e..585878fc 100644 --- a/back/tests/Kyoo.Tests/KAssert.cs +++ b/back/tests/Kyoo.Tests/KAssert.cs @@ -18,6 +18,7 @@ using FluentAssertions; using JetBrains.Annotations; +using Kyoo.Abstractions.Models; using Xunit.Sdk; namespace Kyoo.Tests @@ -36,6 +37,22 @@ namespace Kyoo.Tests [AssertionMethod] public static void DeepEqual(T expected, T value) { + if (expected is IResource res && expected is IThumbnails thumbs) { + if (thumbs.Poster != null) + thumbs.Poster.Path = $"/{expected.GetType().Name.ToLower()}/{res.Slug}/poster"; + if (thumbs.Thumbnail != null) + thumbs.Thumbnail.Path = $"/{expected.GetType().Name.ToLower()}/{res.Slug}/thumbnail"; + if (thumbs.Logo != null) + thumbs.Logo.Path = $"/{expected.GetType().Name.ToLower()}/{res.Slug}/logo"; + } + if (value is IResource resV && value is IThumbnails thumbsV) { + if (thumbsV.Poster != null) + thumbsV.Poster.Path = $"/{value.GetType().Name.ToLower()}/{resV.Slug}/poster"; + if (thumbsV.Thumbnail != null) + thumbsV.Thumbnail.Path = $"/{value.GetType().Name.ToLower()}/{resV.Slug}/thumbnail"; + if (thumbsV.Logo != null) + thumbsV.Logo.Path = $"/{value.GetType().Name.ToLower()}/{resV.Slug}/logo"; + } value.Should().BeEquivalentTo(expected); }