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

pull/94/head
Taloth Saldono 10 years ago
parent b0c45aef50
commit b427954f5f

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

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

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

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

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

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

@ -3,6 +3,7 @@ using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Download.Pending; using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Housekeeping.Housekeepers; using NzbDrone.Core.Housekeeping.Housekeepers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -15,6 +16,8 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
public void should_delete_orphaned_pending_items() public void should_delete_orphaned_pending_items()
{ {
var pendingRelease = Builder<PendingRelease>.CreateNew() var pendingRelease = Builder<PendingRelease>.CreateNew()
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
.With(h => h.Release = new ReleaseInfo())
.BuildNew(); .BuildNew();
Db.Insert(pendingRelease); Db.Insert(pendingRelease);
@ -31,6 +34,8 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
var pendingRelease = Builder<PendingRelease>.CreateNew() var pendingRelease = Builder<PendingRelease>.CreateNew()
.With(h => h.SeriesId = series.Id) .With(h => h.SeriesId = series.Id)
.With(h => h.ParsedEpisodeInfo = new ParsedEpisodeInfo())
.With(h => h.Release = new ReleaseInfo())
.BuildNew(); .BuildNew();
Db.Insert(pendingRelease); Db.Insert(pendingRelease);

@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.MediaFiles
Subject.Execute(new DownloadedEpisodesScanCommand()); Subject.Execute(new DownloadedEpisodesScanCommand());
Mocker.GetMock<IMakeImportDecision>() 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()); Times.Never());
VerifyNoImport(); VerifyNoImport();

@ -2,6 +2,7 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -25,7 +26,9 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
[Test] [Test]
public void should_get_episodes_by_file() 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); Db.Insert(episodeFile);

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

@ -55,6 +55,7 @@ namespace NzbDrone.Core.Datastore.Converters
public object ToDB(object clrValue) public object ToDB(object clrValue)
{ {
if (clrValue == null) return null; if (clrValue == null) return null;
if (clrValue == DBNull.Value) return DBNull.Value;
return JsonConvert.SerializeObject(clrValue, SerializerSetting); return JsonConvert.SerializeObject(clrValue, SerializerSetting);
} }

Loading…
Cancel
Save