Fix back tests

This commit is contained in:
Zoe Roux 2023-09-07 22:55:16 +02:00
parent 4217d471c4
commit 7ad1383acb
2 changed files with 13 additions and 2 deletions

View File

@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -284,6 +285,8 @@ namespace Kyoo.Tests.Database
await _repository.Create(value);
ICollection<Episode> ret = await _repository.Search(query);
value.Show = TestSample.Get<Show>();
value.Show.AddedDate = DateTime.UnixEpoch;
ret.First().Show.AddedDate = DateTime.UnixEpoch;
KAssert.DeepEqual(value, ret.First());
}

View File

@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
using System;
using FluentAssertions;
using JetBrains.Annotations;
using Kyoo.Abstractions.Models;
@ -37,7 +38,8 @@ namespace Kyoo.Tests
[AssertionMethod]
public static void DeepEqual<T>(T expected, T value)
{
if (expected is IResource res && expected is IThumbnails thumbs) {
if (expected is IResource res and IThumbnails thumbs)
{
if (thumbs.Poster != null)
thumbs.Poster.Path = $"/{expected.GetType().Name.ToLower()}/{res.Slug}/poster";
if (thumbs.Thumbnail != null)
@ -45,7 +47,8 @@ namespace Kyoo.Tests
if (thumbs.Logo != null)
thumbs.Logo.Path = $"/{expected.GetType().Name.ToLower()}/{res.Slug}/logo";
}
if (value is IResource resV && value is IThumbnails thumbsV) {
if (value is IResource resV and IThumbnails thumbsV)
{
if (thumbsV.Poster != null)
thumbsV.Poster.Path = $"/{value.GetType().Name.ToLower()}/{resV.Slug}/poster";
if (thumbsV.Thumbnail != null)
@ -53,6 +56,11 @@ namespace Kyoo.Tests
if (thumbsV.Logo != null)
thumbsV.Logo.Path = $"/{value.GetType().Name.ToLower()}/{resV.Slug}/logo";
}
if (expected is IAddedDate ea && value is IAddedDate va)
{
ea.AddedDate = DateTime.UnixEpoch;
va.AddedDate = DateTime.UnixEpoch;
}
value.Should().BeEquivalentTo(expected);
}