1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

null EmbeddedDocuments are now stored as DBNull instead of json null.

This commit is contained in:
Taloth Saldono 2014-07-28 13:16:40 +02:00
parent b0c45aef50
commit b427954f5f
11 changed files with 47 additions and 11 deletions

View File

@ -36,6 +36,7 @@ public void Setup()
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
.All()
.With(v => v.SeriesId = series[0].Id)
.With(v => v.Quality = new QualityModel())
.BuildListOfNew();
Db.InsertMany(episodeFiles);

View File

@ -4,6 +4,7 @@
using NUnit.Framework;
using NzbDrone.Core.History;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.Test.HistoryTests
{
@ -15,7 +16,8 @@ public void Trim_Items()
{
var historyItem = Builder<History.History>.CreateListOfSize(30)
.All()
.With(c=>c.Id = 0)
.With(c => c.Id = 0)
.With(c => c.Quality = new QualityModel())
.TheFirst(10).With(c => c.Date = DateTime.Now)
.TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
.Build();
@ -32,7 +34,9 @@ public void Trim_Items()
[Test]
public void should_read_write_dictionary()
{
var history = Builder<History.History>.CreateNew().BuildNew();
var history = Builder<History.History>.CreateNew()
.With(c => c.Quality = new QualityModel())
.BuildNew();
history.Data.Add("key1","value1");
history.Data.Add("key2","value2");
@ -48,6 +52,7 @@ public void grabbed_should_return_grabbed_items()
var history = Builder<History.History>
.CreateListOfSize(5)
.All()
.With(c => c.Quality = new QualityModel())
.With(c => c.EventType = HistoryEventType.Unknown)
.Random(3)
.With(c => c.EventType = HistoryEventType.Grabbed)

View File

@ -3,8 +3,11 @@
using NUnit.Framework;
using NzbDrone.Core.Blacklisting;
using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using System;
using System.Collections.Generic;
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
{
@ -15,6 +18,8 @@ public class CleanupOrphanedBlacklistFixture : DbTest<CleanupOrphanedBlacklist,
public void should_delete_orphaned_blacklist_items()
{
var blacklist = Builder<Blacklist>.CreateNew()
.With(h => h.EpisodeIds = new List<Int32>())
.With(h => h.Quality = new QualityModel())
.BuildNew();
Db.Insert(blacklist);
@ -30,8 +35,10 @@ public void should_not_delete_unorphaned_blacklist_items()
Db.Insert(series);
var blacklist = Builder<Blacklist>.CreateNew()
.With(b => b.SeriesId = series.Id)
.BuildNew();
.With(h => h.EpisodeIds = new List<Int32>())
.With(h => h.Quality = new QualityModel())
.With(b => b.SeriesId = series.Id)
.BuildNew();
Db.Insert(blacklist);

View File

@ -6,6 +6,7 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
{
@ -16,6 +17,7 @@ public class CleanupOrphanedEpisodeFilesFixture : DbTest<CleanupOrphanedEpisodeF
public void should_delete_orphaned_episode_files()
{
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(h => h.Quality = new QualityModel())
.BuildNew();
Db.Insert(episodeFile);
@ -27,6 +29,8 @@ public void should_delete_orphaned_episode_files()
public void should_not_delete_unorphaned_episode_files()
{
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.All()
.With(h => h.Quality = new QualityModel())
.BuildListOfNew();
Db.InsertMany(episodeFiles);

View File

@ -2,6 +2,7 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -39,6 +40,7 @@ public void should_delete_orphaned_items_by_series()
GivenEpisode();
var history = Builder<History.History>.CreateNew()
.With(h => h.Quality = new QualityModel())
.With(h => h.EpisodeId = _episode.Id)
.BuildNew();
Db.Insert(history);
@ -53,6 +55,7 @@ public void should_delete_orphaned_items_by_episode()
GivenSeries();
var history = Builder<History.History>.CreateNew()
.With(h => h.Quality = new QualityModel())
.With(h => h.SeriesId = _series.Id)
.BuildNew();
Db.Insert(history);
@ -69,6 +72,7 @@ public void should_not_delete_unorphaned_data_by_series()
var history = Builder<History.History>.CreateListOfSize(2)
.All()
.With(h => h.Quality = new QualityModel())
.With(h => h.EpisodeId = _episode.Id)
.TheFirst(1)
.With(h => h.SeriesId = _series.Id)
@ -89,6 +93,7 @@ public void should_not_delete_unorphaned_data_by_episode()
var history = Builder<History.History>.CreateListOfSize(2)
.All()
.With(h => h.Quality = new QualityModel())
.With(h => h.SeriesId = _series.Id)
.TheFirst(1)
.With(h => h.EpisodeId = _episode.Id)

View File

@ -5,6 +5,7 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Metadata;
using NzbDrone.Core.Metadata.Files;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -68,6 +69,7 @@ public void should_not_delete_metadata_files_that_have_a_coresponding_episode_fi
.BuildNew();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(h => h.Quality = new QualityModel())
.BuildNew();
Db.Insert(series);

View File

@ -3,6 +3,7 @@
using NUnit.Framework;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -15,7 +16,9 @@ public class CleanupOrphanedPendingReleasesFixture : DbTest<CleanupOrphanedPendi
public void should_delete_orphaned_pending_items()
{
var pendingRelease = Builder<PendingRelease>.CreateNew()
.BuildNew();
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
.With(h => h.Release = new ReleaseInfo())
.BuildNew();
Db.Insert(pendingRelease);
Subject.Clean();
@ -30,8 +33,10 @@ public void should_not_delete_unorphaned_pending_items()
Db.Insert(series);
var pendingRelease = Builder<PendingRelease>.CreateNew()
.With(h => h.SeriesId = series.Id)
.BuildNew();
.With(h => h.SeriesId = series.Id)
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
.With(h => h.Release = new ReleaseInfo())
.BuildNew();
Db.Insert(pendingRelease);

View File

@ -95,7 +95,7 @@ public void should_skip_if_no_series_found()
Subject.Execute(new DownloadedEpisodesScanCommand());
Mocker.GetMock<IMakeImportDecision>()
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<bool>(), It.IsAny<Core.Qualities.QualityModel>()),
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<bool>(), It.IsAny<QualityModel>()),
Times.Never());
VerifyNoImport();

View File

@ -2,6 +2,7 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -25,7 +26,9 @@ public void Setup()
[Test]
public void should_get_episodes_by_file()
{
var episodeFile = Builder<EpisodeFile>.CreateNew().BuildNew();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(h => h.Quality = new QualityModel())
.BuildNew();
Db.Insert(episodeFile);

View File

@ -7,6 +7,7 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Qualities;
namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
{
@ -21,8 +22,9 @@ public class EpisodesWithFilesFixture : DbTest<EpisodeRepository, Episode>
public void Setup()
{
_episodeFiles = Builder<EpisodeFile>.CreateListOfSize(5)
.BuildListOfNew()
.ToList();
.All()
.With(c => c.Quality = new QualityModel())
.BuildListOfNew();
Db.InsertMany(_episodeFiles);
@ -56,6 +58,7 @@ public void should_only_contain_episodes_for_the_given_series()
{
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Path = "another path")
.With(c => c.Quality = new QualityModel())
.BuildNew();
Db.Insert(episodeFile);

View File

@ -55,6 +55,7 @@ public object FromDB(ColumnMap map, object dbValue)
public object ToDB(object clrValue)
{
if (clrValue == null) return null;
if (clrValue == DBNull.Value) return DBNull.Value;
return JsonConvert.SerializeObject(clrValue, SerializerSetting);
}