1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-19 21:46:50 -04:00

post grab notification and updates are now using the new EventAggregator

This commit is contained in:
kay.one
2013-02-24 11:18:48 -08:00
parent 13658e3c6d
commit 554924a522
40 changed files with 670 additions and 482 deletions
@@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
namespace NzbDrone.Core.Test.Configuration
{
[TestFixture]
public class ConfigCachingFixture : CoreTest<ConfigService>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<IConfigRepository>().Setup(c => c.All())
.Returns(new List<Config> { new Config { Key = "Key1", Value = "Value1" } });
}
[Test]
public void getting_value_more_than_once_should_hit_db_once()
{
Subject.GetValue("Key1", null).Should().Be("Value1");
Subject.GetValue("Key1", null).Should().Be("Value1");
Subject.GetValue("Key1", null).Should().Be("Value1");
Mocker.GetMock<IConfigRepository>().Verify(c => c.All(), Times.Once());
}
}
}
@@ -0,0 +1,183 @@
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Configuration
{
[TestFixture]
public class ConfigServiceFixture : ObjectDbTest<ConfigService, Config>
{
[SetUp]
public void SetUp()
{
Mocker.Resolve<IConfigRepository, ConfigRepository>();
}
[Test]
public void Add_new_value_to_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Subject.SetValue(key, value);
Subject.GetValue(key, "").Should().Be(value);
}
[Test]
public void Get_value_from_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Db.Insert(new Config { Key = key, Value = value });
Db.Insert(new Config { Key = "Other Key", Value = "OtherValue" });
var result = Subject.GetValue(key, "");
result.Should().Be(value);
}
[Test]
public void Get_value_should_return_default_when_no_value()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
var result = Subject.GetValue(key, value);
result.Should().Be(value);
}
[Test]
public void New_value_should_update_old_value_new_value()
{
const string key = "MY_KEY";
const string originalValue = "OLD_VALUE";
const string newValue = "NEW_VALUE";
Db.Insert(new Config { Key = key, Value = originalValue });
//Act
Subject.SetValue(key, newValue);
var result = Subject.GetValue(key, "");
//Assert
result.Should().Be(newValue);
AllStoredModels.Should().HaveCount(1);
}
[Test]
public void New_value_should_update_old_value_same_value()
{
const string key = "MY_KEY";
const string value = "OLD_VALUE";
Subject.SetValue(key, value);
Subject.SetValue(key, value);
var result = Subject.GetValue(key, "");
result.Should().Be(value);
AllStoredModels.Should().HaveCount(1);
}
[Test]
public void get_value_with_persist_should_store_default_value()
{
const string key = "MY_KEY";
string value = Guid.NewGuid().ToString();
Subject.GetValue(key, value, persist: true).Should().Be(value);
Subject.GetValue(key, string.Empty).Should().Be(value);
}
[Test]
public void get_value_with_out_persist_should_not_store_default_value()
{
const string key = "MY_KEY";
string value1 = Guid.NewGuid().ToString();
string value2 = Guid.NewGuid().ToString();
Subject.GetValue(key, value1).Should().Be(value1);
Subject.GetValue(key, value2).Should().Be(value2);
}
[Test]
public void uguid_should_only_be_set_once()
{
var guid1 = Subject.UGuid;
var guid2 = Subject.UGuid;
guid1.Should().Be(guid2);
}
[Test]
public void uguid_should_return_valid_result_on_first_call()
{
var guid = Subject.UGuid;
guid.Should().NotBeEmpty();
}
[Test]
public void updating_a_vakye_should_update_its_value()
{
Subject.SabHost = "Test";
Subject.SabHost.Should().Be("Test");
Subject.SabHost = "Test2";
Subject.SabHost.Should().Be("Test2");
}
[Test]
[Description("This test will use reflection to ensure each config property read/writes to a unique key")]
public void config_properties_should_write_and_read_using_same_key()
{
var configProvider = Subject;
var allProperties = typeof(ConfigService).GetProperties().Where(p => p.GetSetMethod() != null).ToList();
//Act
foreach (var propertyInfo in allProperties)
{
object value = null;
if (propertyInfo.PropertyType == typeof(string))
{
value = new Guid().ToString();
}
else if (propertyInfo.PropertyType == typeof(int))
{
value = DateTime.Now.Millisecond;
}
else if (propertyInfo.PropertyType == typeof(bool))
{
value = true;
}
else if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
value = 0;
}
propertyInfo.GetSetMethod().Invoke(configProvider, new[] { value });
var returnValue = propertyInfo.GetGetMethod().Invoke(configProvider, null);
if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
returnValue = (int)returnValue;
}
returnValue.Should().Be(value, propertyInfo.Name);
}
AllStoredModels.Should()
.HaveSameCount(allProperties, "two different properties are writing to the same key in db. Copy/Past fail.");
}
}
}
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Tv;
@@ -131,5 +133,123 @@ namespace NzbDrone.Core.Test
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p [proper]");
}
public static readonly object[] SabNamingCases =
{
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
new object[] { 1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
};
[Test, TestCaseSource("SabNamingCases")]
public void create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string expected)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var fakeEpisodes = new List<Episode>();
foreach (var episode in episodes)
fakeEpisodes.Add(Builder<Episode>
.CreateNew()
.With(e => e.EpisodeNumber = episode)
.With(e => e.Title = title)
.Build());
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
EpisodeNumbers = episodes.ToList(),
Quality = new QualityModel(quality, proper),
SeasonNumber = seasons,
Series = series,
EpisodeTitle = title,
Episodes = fakeEpisodes
};
parsResult.GetDownloadTitle().Should().Be(expected);
}
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]
[TestCase(false, Result = "My Series Name - Season 1 [Bluray720p]")]
public string create_proper_sab_season_title(bool proper)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
SeasonNumber = 1,
Series = series,
EpisodeTitle = "My Episode Title",
FullSeason = true
};
return parsResult.GetDownloadTitle();
}
[TestCase(true, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p] [Proper]")]
[TestCase(false, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
public string create_proper_sab_daily_titles(bool proper)
{
var series = Builder<Series>.CreateNew()
.With(c => c.SeriesType = SeriesType.Daily)
.With(c => c.Title = "My Series Name")
.Build();
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "My Episode Title")
.Build();
var parsResult = new EpisodeParseResult
{
AirDate = new DateTime(2011, 12, 1),
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
Series = series,
EpisodeTitle = "My Episode Title",
Episodes = new List<Episode> { episode }
};
return parsResult.GetDownloadTitle();
}
[Test]
public void should_not_repeat_the_same_episode_title()
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
.With(e => e.SeasonNumber = 5)
.TheFirst(1)
.With(e => e.Title = "My Episode Title (1)")
.TheLast(1)
.With(e => e.Title = "My Episode Title (2)")
.Build();
var parsResult = new EpisodeParseResult
{
AirDate = DateTime.Now,
EpisodeNumbers = new List<int> { 10, 11 },
Quality = new QualityModel(QualityTypes.HDTV720p, false),
SeasonNumber = 35,
Series = series,
Episodes = fakeEpisodes
};
parsResult.GetDownloadTitle().Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV-720p]");
}
}
}
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -112,10 +113,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Returns(fi);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel { Quality = QualityTypes.WEBDL720p, Proper = false })))
.Returns(message);
Mocker.GetMock<DiskProvider>()
.Setup(s => s.FileExists(currentFilename))
.Returns(true);
@@ -175,10 +172,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
.Returns(fi);
Mocker.GetMock<DownloadProvider>()
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel { Quality = QualityTypes.WEBDL720p, Proper = false })))
.Returns(message);
Mocker.GetMock<ExternalNotificationProvider>()
.Setup(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()));
@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
@@ -6,11 +6,9 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
@@ -20,17 +18,9 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
{
[TestFixture]
public class DownloadProviderFixture : CoreTest
public class DownloadProviderFixture : CoreTest<DownloadProvider>
{
public static object[] SabNamingCases =
{
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
new object[] { 1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
new object[] { 1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
new object[] { 1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
new object[] { 1, new[] { 2, 4 }, "", QualityTypes.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
};
private void SetDownloadClient(DownloadClientType clientType)
{
@@ -53,7 +43,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
return Builder<EpisodeParseResult>.CreateNew()
.With(c => c.Quality = new QualityModel(QualityTypes.DVD, false))
.With(c => c.Series = Builder<Series>.CreateNew().Build())
.With(c => c.EpisodeNumbers = new List<int>{2})
.With(c => c.EpisodeNumbers = new List<int> { 2 })
.With(c => c.Episodes = episodes)
.Build();
}
@@ -81,7 +71,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
}
[Test]
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
public void Download_report_should_publish_on_grab_event()
{
WithSuccessfullAdd();
SetDownloadClient(DownloadClientType.Sabnzbd);
@@ -89,7 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
var parseResult = SetupParseResult();
//Act
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
Subject.DownloadReport(parseResult);
//Assert
@@ -99,197 +89,39 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
Mocker.GetMock<BlackholeProvider>()
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Never());
Mocker.GetMock<HistoryService>()
.Verify(s => s.Add(It.Is<History.History>(h => h.Episode == parseResult.Episodes[0])), Times.Once());
Mocker.GetMock<HistoryService>()
.Verify(s => s.Add(It.Is<History.History>(h => h.Episode == parseResult.Episodes[1])), Times.Once());
Mocker.GetMock<IEpisodeService>()
.Verify(c => c.MarkEpisodeAsFetched(12));
Mocker.GetMock<IEpisodeService>()
.Verify(c => c.MarkEpisodeAsFetched(99));
Mocker.GetMock<ExternalNotificationProvider>()
.Verify(c => c.OnGrab(It.IsAny<string>()));
}
[Test]
public void should_download_nzb_to_blackhole_add_to_history_mark_as_grabbed()
{
WithSuccessfullAdd();
SetDownloadClient(DownloadClientType.Blackhole);
var parseResult = SetupParseResult();
//Act
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
//Assert
Mocker.GetMock<SabProvider>()
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Never());
Mocker.GetMock<BlackholeProvider>()
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Once());
Mocker.GetMock<HistoryService>()
.Verify(s => s.Add(It.Is<History.History>(h => h.Episode == parseResult.Episodes[0])), Times.Once());
Mocker.GetMock<HistoryService>()
.Verify(s => s.Add(It.Is<History.History>(h => h.Episode == parseResult.Episodes[1])), Times.Once());
Mocker.GetMock<IEpisodeService>()
.Verify(c => c.MarkEpisodeAsFetched(12));
Mocker.GetMock<IEpisodeService>()
.Verify(c => c.MarkEpisodeAsFetched(99));
Mocker.GetMock<ExternalNotificationProvider>()
.Verify(c => c.OnGrab(It.IsAny<string>()));
VerifyEventPublished(It.Is<EpisodeGrabbedEvent>(c => c.ParseResult == parseResult));
}
[TestCase(DownloadClientType.Sabnzbd)]
[TestCase(DownloadClientType.Blackhole)]
public void Download_report_should_not_add_to_history_mark_as_grabbed_if_add_fails(DownloadClientType clientType)
public void Download_report_should_not_publish_grabbed_event(DownloadClientType clientType)
{
WithFailedAdd();
SetDownloadClient(clientType);
var parseResult = SetupParseResult();
//Act
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
Mocker.GetMock<HistoryService>()
.Verify(s => s.Add(It.IsAny<History.History>()), Times.Never());
Subject.DownloadReport(parseResult);
Mocker.GetMock<IEpisodeService>()
.Verify(c => c.MarkEpisodeAsFetched(It.IsAny<int>()), Times.Never());
Mocker.GetMock<ExternalNotificationProvider>()
.Verify(c => c.OnGrab(It.IsAny<String>()), Times.Never());
VerifyEventNotPublished<EpisodeGrabbedEvent>();
}
[Test]
public void should_return_sab_as_active_client()
{
SetDownloadClient(DownloadClientType.Sabnzbd);
Mocker.Resolve<DownloadProvider>().GetActiveDownloadClient().Should().BeAssignableTo<SabProvider>();
Subject.GetActiveDownloadClient().Should().BeAssignableTo<SabProvider>();
}
[Test]
public void should_return_blackhole_as_active_client()
{
SetDownloadClient(DownloadClientType.Blackhole);
Mocker.Resolve<DownloadProvider>().GetActiveDownloadClient().Should().BeAssignableTo<BlackholeProvider>();
Subject.GetActiveDownloadClient().Should().BeAssignableTo<BlackholeProvider>();
}
[Test, TestCaseSource("SabNamingCases")]
public void create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string expected)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var fakeEpisodes = new List<Episode>();
foreach(var episode in episodes)
fakeEpisodes.Add(Builder<Episode>
.CreateNew()
.With(e => e.EpisodeNumber = episode)
.With(e => e.Title = title)
.Build());
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
EpisodeNumbers = episodes.ToList(),
Quality = new QualityModel(quality, proper),
SeasonNumber = seasons,
Series = series,
EpisodeTitle = title,
Episodes = fakeEpisodes
};
Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult).Should().Be(expected);
}
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]
[TestCase(false, Result = "My Series Name - Season 1 [Bluray720p]")]
public string create_proper_sab_season_title(bool proper)
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var parsResult = new EpisodeParseResult()
{
AirDate = DateTime.Now,
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
SeasonNumber = 1,
Series = series,
EpisodeTitle = "My Episode Title",
FullSeason = true
};
return Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult);
}
[TestCase(true, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p] [Proper]")]
[TestCase(false, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
public string create_proper_sab_daily_titles(bool proper)
{
var series = Builder<Series>.CreateNew()
.With(c => c.SeriesType = SeriesType.Daily)
.With(c => c.Title = "My Series Name")
.Build();
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "My Episode Title")
.Build();
var parsResult = new EpisodeParseResult
{
AirDate = new DateTime(2011, 12, 1),
Quality = new QualityModel(QualityTypes.Bluray720p, proper),
Series = series,
EpisodeTitle = "My Episode Title",
Episodes = new List<Episode>{ episode }
};
return Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult);
}
[Test]
public void should_not_repeat_the_same_episode_title()
{
var series = Builder<Series>.CreateNew()
.With(c => c.Title = "My Series Name")
.Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
.With(e => e.SeasonNumber = 5)
.TheFirst(1)
.With(e => e.Title = "My Episode Title (1)")
.TheLast(1)
.With(e => e.Title = "My Episode Title (2)")
.Build();
var parsResult = new EpisodeParseResult
{
AirDate = DateTime.Now,
EpisodeNumbers = new List<int>{ 10, 11 },
Quality = new QualityModel(QualityTypes.HDTV720p, false),
SeasonNumber = 35,
Series = series,
Episodes = fakeEpisodes
};
Mocker.Resolve<DownloadProvider>().GetDownloadTitle(parsResult).Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV-720p]");
}
}
}
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@@ -6,6 +6,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -941,23 +942,17 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void MarkEpisodeAsFetched()
{
WithRealDb();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All().With(e => e.GrabDate = null)
.Build();
Db.InsertMany(fakeEpisodes);
var parseResult = new EpisodeParseResult() { Episodes = fakeEpisodes };
//Act
Mocker.Resolve<EpisodeService>().MarkEpisodeAsFetched(2);
var episodes = Db.Fetch<Episode>();
Mocker.Resolve<EpisodeService>().Handle(new EpisodeGrabbedEvent(parseResult));
//Assert
episodes.Where(e => e.OID == 2).Single().GrabDate.Should().BeWithin(TimeSpan.FromSeconds(5)).Before(
DateTime.Now);
episodes.Where(e => e.GrabDate == null).Should().HaveCount(4);
Mocker.GetMock<IEpisodeRepository>().Verify(c=>c.Update(fakeEpisodes[0]),Times.Once());
Mocker.GetMock<IEpisodeRepository>().Verify(c=>c.Update(fakeEpisodes[1]),Times.Once());
}
[Test]