diff --git a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs index 61dc33105..f907b63ec 100644 --- a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs @@ -22,24 +22,21 @@ namespace NzbDrone.Core.Test.ProviderTests [TestCase(false)] public void Add_new_series(bool useSeasonFolder) { - var mocker = new AutoMoqer(); + WithRealDb(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); - var fakeProfiles = Builder.CreateListOfSize(2).Build(); - db.InsertMany(fakeProfiles); + Db.InsertMany(fakeProfiles); const string path = "C:\\Test\\"; const int tvDbId = 1234; const int qualityProfileId = 2; //Act - var seriesProvider = mocker.Resolve(); + var seriesProvider = Mocker.Resolve(); seriesProvider.AddSeries(path, tvDbId, qualityProfileId); //Assert @@ -54,14 +51,12 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void find_series_empty_repo() { - var mocker = new AutoMoqer(); - mocker.SetConstant(TestDbHelper.GetEmptyDatabase()); + WithRealDb(); //Act - var seriesProvider = mocker.Resolve(); + var seriesProvider = Mocker.Resolve(); var series = seriesProvider.FindSeries("My Title"); - //Assert Assert.IsNull(series); } @@ -70,11 +65,10 @@ namespace NzbDrone.Core.Test.ProviderTests [ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")] public void Get_series_invalid_series_id_should_return_null() { - var mocker = new AutoMoqer(); - mocker.SetConstant(TestDbHelper.GetEmptyDatabase()); + WithRealDb(); //Act - var seriesProvider = mocker.Resolve(); + var seriesProvider = Mocker.Resolve(); var series = seriesProvider.GetSeries(2); @@ -85,9 +79,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_series_by_id() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeSeries = Builder.CreateNew() .With(c => c.QualityProfileId = 1) @@ -97,12 +89,12 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetSeries(1); + Mocker.Resolve(); + var series = Mocker.Resolve().GetSeries(1); //Assert series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries); @@ -114,9 +106,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Find_series_by_cleanName_mapped() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeSeries = Builder.CreateNew() .With(c => c.QualityProfileId = 1) @@ -124,14 +114,14 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - var id = db.Insert(fakeSeries); - db.Insert(fakeQuality); + var id = Db.Insert(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - mocker.GetMock().Setup(s => s.GetSeriesId("laworder")).Returns(1); + Mocker.Resolve(); + Mocker.GetMock().Setup(s => s.GetSeriesId("laworder")).Returns(1); - var series = mocker.Resolve().FindSeries("laworder"); + var series = Mocker.Resolve().FindSeries("laworder"); //Assert series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId); @@ -142,12 +132,11 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void find_series_empty_match() { - var mocker = new AutoMoqer(); - var emptyRepository = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(emptyRepository); - emptyRepository.Insert(TestDbHelper.GetFakeSeries(1, "MyTitle")); + WithRealDb(); + + Db.Insert(TestDbHelper.GetFakeSeries(1, "MyTitle")); //Act - var seriesProvider = mocker.Resolve(); + var seriesProvider = Mocker.Resolve(); var series = seriesProvider.FindSeries("WrongTitle"); @@ -159,15 +148,14 @@ namespace NzbDrone.Core.Test.ProviderTests [TestCase("Through the Wormhole", "Through.the.Wormhole")] public void find_series_match(string title, string searchTitle) { - var mocker = new AutoMoqer(); - var emptyRepository = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(emptyRepository); - emptyRepository.Insert(TestDbHelper.GetFakeSeries(1, title)); - emptyRepository.Insert(Builder.CreateNew().Build()); - mocker.Resolve(); + WithRealDb(); + + Db.Insert(TestDbHelper.GetFakeSeries(1, title)); + Db.Insert(Builder.CreateNew().Build()); + Mocker.Resolve(); //Act - var seriesProvider = mocker.Resolve(); + var seriesProvider = Mocker.Resolve(); var series = seriesProvider.FindSeries(searchTitle); //Assert @@ -180,27 +168,22 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void is_monitored() { - var mocker = new AutoMoqer(); + WithRealDb(); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); - - mocker.SetConstant(db); - - db.Insert(Builder.CreateNew() + Db.Insert(Builder.CreateNew() .With(c => c.Monitored = true) .With(c => c.SeriesId = 12) .Build()); - db.Insert(Builder.CreateNew() + Db.Insert(Builder.CreateNew() .With(c => c.Monitored = false) .With(c => c.SeriesId = 11) .Build()); - db.InsertMany(Builder.CreateListOfSize(3).Build()); + Db.InsertMany(Builder.CreateListOfSize(3).Build()); //Act, Assert - var provider = mocker.Resolve(); + var provider = Mocker.Resolve(); provider.IsMonitored(12).Should().BeTrue(); Assert.IsFalse(provider.IsMonitored(11)); Assert.IsFalse(provider.IsMonitored(1)); @@ -209,9 +192,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_With_Count() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -225,13 +206,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.AirDate = DateTime.Today.AddDays(1)) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -242,21 +223,19 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_With_Count_AllIgnored() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeEpisodes = Builder.CreateListOfSize(10).All().With(e => e.SeriesId = fakeSeries.SeriesId).With(e => e.Ignored = true).Random(5).With(e => e.EpisodeFileId = 0).Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -267,9 +246,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_With_Count_AllDownloaded() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -280,13 +257,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.AirDate = DateTime.Today.AddDays(-1)) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -297,9 +274,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_With_Count_Half_Ignored() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -313,13 +288,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.Ignored = true) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -330,9 +305,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Single_Series() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew() @@ -340,12 +313,12 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.SeriesId = 1) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetSeries(1); + Mocker.Resolve(); + var series = Mocker.Resolve().GetSeries(1); //Assert series.QualityProfile.Should().NotBeNull(); @@ -355,9 +328,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SeriesPathExists_exact_match() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var path = @"C:\Test\TV\30 Rock"; @@ -369,15 +340,15 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - //mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( + Mocker.Resolve(); + //Mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( //fakeSeries.ToList()); - var result = mocker.Resolve().SeriesPathExists(path); + var result = Mocker.Resolve().SeriesPathExists(path); //Assert result.Should().BeTrue(); @@ -386,9 +357,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SeriesPathExists_match() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var path = @"C:\Test\TV\30 Rock"; @@ -400,15 +369,15 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - //mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( + Mocker.Resolve(); + //Mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( //fakeSeries.ToList()); - var result = mocker.Resolve().SeriesPathExists(path.ToUpper()); + var result = Mocker.Resolve().SeriesPathExists(path.ToUpper()); //Assert result.Should().BeTrue(); @@ -417,9 +386,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SeriesPathExists_match_alt() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var path = @"C:\Test\TV\The Simpsons"; @@ -431,15 +398,15 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - //mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( + Mocker.Resolve(); + //Mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( //fakeSeries.ToList()); - var result = mocker.Resolve().SeriesPathExists(@"c:\Test\Tv\the sIMpsons"); + var result = Mocker.Resolve().SeriesPathExists(@"c:\Test\Tv\the sIMpsons"); //Assert result.Should().BeTrue(); @@ -448,9 +415,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SeriesPathExists_match_false() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var path = @"C:\Test\TV\30 Rock"; @@ -462,15 +427,15 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); var fakeQuality = Builder.CreateNew().Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - mocker.Resolve(); - //mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( + Mocker.Resolve(); + //Mocker.GetMock().Setup(s => s.Fetch(It.IsAny())).Returns( //fakeSeries.ToList()); - var result = mocker.Resolve().SeriesPathExists(@"C:\Test\TV\Not A match"); + var result = Mocker.Resolve().SeriesPathExists(@"C:\Test\TV\Not A match"); //Assert result.Should().BeFalse(); @@ -479,9 +444,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_NextAiring_Today() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -494,13 +457,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.AirDate = DateTime.Today) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -510,9 +473,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -525,13 +486,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.AirDate = DateTime.Today.AddDays(-1)) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -541,9 +502,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_NextAiring_Unknown() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -554,13 +513,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.Ignored = false) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -570,9 +529,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_NextAiring_1_month() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -585,13 +542,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.AirDate = DateTime.Today.AddDays(-1)) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -601,9 +558,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void Get_Series_NextAiring_skip_ignored() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); @@ -617,13 +572,13 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.Ignored = true) .Build(); - db.Insert(fakeSeries); - db.Insert(fakeQuality); - db.InsertMany(fakeEpisodes); + Db.Insert(fakeSeries); + Db.Insert(fakeQuality); + Db.InsertMany(fakeEpisodes); //Act - mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); + Mocker.Resolve(); + var series = Mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -633,9 +588,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SearchForSeries_should_return_results_that_start_with_query() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateListOfSize(10) @@ -643,11 +596,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - var series = mocker.Resolve().SearchForSeries("Titl"); + var series = Mocker.Resolve().SearchForSeries("Titl"); //Assert series.Should().HaveCount(10); @@ -656,9 +609,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SearchForSeries_should_return_results_that_contain_the_query() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateListOfSize(10) @@ -666,11 +617,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - var series = mocker.Resolve().SearchForSeries("itl"); + var series = Mocker.Resolve().SearchForSeries("itl"); //Assert series.Should().HaveCount(10); @@ -679,9 +630,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SearchForSeries_should_return_results_that_end_with_the_query() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateListOfSize(10) @@ -689,11 +638,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - var series = mocker.Resolve().SearchForSeries("2"); + var series = Mocker.Resolve().SearchForSeries("2"); //Assert series.Should().HaveCount(1); @@ -702,9 +651,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SearchForSeries_should_not_return_results_that_do_not_contain_the_query() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateListOfSize(10) @@ -712,11 +659,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - var series = mocker.Resolve().SearchForSeries("NotATitle"); + var series = Mocker.Resolve().SearchForSeries("NotATitle"); //Assert series.Should().HaveCount(0); @@ -725,9 +672,7 @@ namespace NzbDrone.Core.Test.ProviderTests [Test] public void SearchForSeries_should_return_results_when_query_has_special_characters() { - var mocker = new AutoMoqer(MockBehavior.Strict); - var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + WithRealDb(); var fakeQuality = Builder.CreateNew().Build(); var fakeSeries = Builder.CreateListOfSize(10) @@ -737,11 +682,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(s => s.Title = "It's Always Sunny") .Build(); - db.InsertMany(fakeSeries); - db.Insert(fakeQuality); + Db.InsertMany(fakeSeries); + Db.Insert(fakeQuality); //Act - var series = mocker.Resolve().SearchForSeries("it's"); + var series = Mocker.Resolve().SearchForSeries("it's"); //Assert series.Should().HaveCount(1);