mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 01:11:43 +00:00
fixed history->episode relationship.
This commit is contained in:
parent
e0b881fe4b
commit
a2b91b469e
3 changed files with 32 additions and 13 deletions
|
@ -4,14 +4,14 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
[TestFixture]
|
||||
public class DatabaseJoinFixture : DbTest<BasicRepository<Series>, Series>
|
||||
public class DatabaseRelationshipFixture : DbTest
|
||||
{
|
||||
[Test]
|
||||
[Explicit]
|
||||
|
@ -23,7 +23,7 @@ public void benchmark()
|
|||
|
||||
Marr.Data.MapRepository.Instance.EnableTraceLogging = false;
|
||||
|
||||
Subject.Insert(series);
|
||||
Db.Insert(series);
|
||||
|
||||
var covers = Builder<MediaCover.MediaCover>.CreateListOfSize(5)
|
||||
.All()
|
||||
|
@ -34,12 +34,12 @@ public void benchmark()
|
|||
|
||||
Db.InsertMany(covers);
|
||||
|
||||
var loadedSeries = Subject.SingleOrDefault();
|
||||
var loadedSeries = Db.Single<Series>();
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
loadedSeries = Subject.SingleOrDefault();
|
||||
loadedSeries = Db.Single<Series>();
|
||||
var list = loadedSeries.Covers.Value;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public void one_to_many()
|
|||
.With(c => c.Id = 0)
|
||||
.Build();
|
||||
|
||||
Subject.Insert(series);
|
||||
Db.Insert(series);
|
||||
|
||||
var covers = Builder<MediaCover.MediaCover>.CreateListOfSize(5)
|
||||
.All()
|
||||
|
@ -68,14 +68,12 @@ public void one_to_many()
|
|||
|
||||
Db.InsertMany(covers);
|
||||
|
||||
var loadedSeries = Subject.SingleOrDefault();
|
||||
loadedSeries = Subject.SingleOrDefault();
|
||||
|
||||
var loadedSeries = Db.Single<Series>();
|
||||
loadedSeries.Covers.Value.Should().HaveSameCount(covers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void embeded_document_as_json()
|
||||
public void one_to_one()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.Id = 0)
|
||||
|
@ -91,7 +89,28 @@ public void embeded_document_as_json()
|
|||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
Db.Single<History.History>().Episode.Value.Should().NotBeNull();
|
||||
|
||||
var loadedEpisode = Db.Single<History.History>().Episode.Value;
|
||||
|
||||
loadedEpisode.Should().NotBeNull();
|
||||
loadedEpisode.ShouldHave().AllProperties().EqualTo(episode);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void embedded_document_as_json()
|
||||
{
|
||||
var quality = new QualityModel { Quality = Quality.Bluray720p, Proper = true };
|
||||
|
||||
var history = Builder<History.History>.CreateNew()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Quality = quality)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
|
||||
var loadedQuality = Db.Single<History.History>().Quality;
|
||||
loadedQuality.Should().Be(quality);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -138,7 +138,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
|
||||
<Compile Include="Datastore\DatabaseJoinFixture.cs" />
|
||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="Framework\DbTest.cs" />
|
||||
|
|
|
@ -40,7 +40,7 @@ public static void Map()
|
|||
Mapper.Entity<History.History>().RegisterModel("History")
|
||||
.Relationships.AutoMapComplexTypeProperties<ILazyLoaded>()
|
||||
.For(c => c.Episode)
|
||||
.LazyLoad((db, history) => db.Query<Episode>().Where(ep => ep.Id == history.Id).ToList());
|
||||
.LazyLoad((db, history) => db.Query<Episode>().Single(ep => ep.Id == history.EpisodeId));
|
||||
|
||||
Mapper.Entity<Series>().RegisterModel("Series")
|
||||
.Relationships.AutoMapComplexTypeProperties<ILazyLoaded>()
|
||||
|
|
Loading…
Reference in a new issue