From c90a96c2e0c752ef6d7195f2b2e769bccf56539c Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 3 Sep 2013 23:15:35 -0700 Subject: [PATCH] fixed broken tests --- .../MetadataSourceTests/TraktProxyFixture.cs | 3 +++ .../EpisodesWithoutFilesFixture.cs | 9 ++++++++- .../Migration/Framework/NzbDroneMigrationBase.cs | 2 +- NzbDrone.Test.Common/TestBase.cs | 13 +++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs b/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs index 52715f18c..ce033fdac 100644 --- a/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs +++ b/NzbDrone.Core.Test/MetadataSourceTests/TraktProxyFixture.cs @@ -7,6 +7,7 @@ using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Rest; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; using NzbDrone.Test.Common.Categories; namespace NzbDrone.Core.Test.MetadataSourceTests @@ -51,6 +52,8 @@ namespace NzbDrone.Core.Test.MetadataSourceTests public void getting_details_of_invalid_series() { Assert.Throws(() => Subject.GetSeriesInfo(Int32.MaxValue)); + + ExceptionVerification.ExpectedWarns(1); } private void ValidateSeries(Series series) diff --git a/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs b/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs index 496bcf77e..e08d77b23 100644 --- a/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs +++ b/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs @@ -14,20 +14,24 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests private Series _monitoredSeries; private Series _unmonitoredSeries; private PagingSpec _pagingSpec; - + [SetUp] public void Setup() { _monitoredSeries = Builder.CreateNew() .With(s => s.Id = 0) + .With(s => s.TvRageId = RandomNumber) .With(s => s.Runtime = 30) .With(s => s.Monitored = true) + .With(s => s.TitleSlug = "Title3") .Build(); _unmonitoredSeries = Builder.CreateNew() .With(s => s.Id = 0) + .With(s => s.TvdbId = RandomNumber) .With(s => s.Runtime = 30) .With(s => s.Monitored = false) + .With(s => s.TitleSlug = "Title2") .Build(); _monitoredSeries.Id = Db.Insert(_monitoredSeries).Id; @@ -44,6 +48,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests var monitoredSeriesEpisodes = Builder.CreateListOfSize(3) .All() .With(e => e.Id = 0) + .With(e => e.TvDbEpisodeId = RandomNumber) .With(e => e.SeriesId = _monitoredSeries.Id) .With(e => e.EpisodeFileId = 0) .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) @@ -57,6 +62,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests var unmonitoredSeriesEpisodes = Builder.CreateListOfSize(3) .All() .With(e => e.Id = 0) + .With(e => e.TvDbEpisodeId = RandomNumber) .With(e => e.SeriesId = _unmonitoredSeries.Id) .With(e => e.EpisodeFileId = 0) .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) @@ -67,6 +73,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests .With(e => e.SeasonNumber = 0) .Build(); + Db.InsertMany(monitoredSeriesEpisodes); Db.InsertMany(unmonitoredSeriesEpisodes); } diff --git a/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs b/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs index c641d5f55..a1be291fe 100644 --- a/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs +++ b/NzbDrone.Core/Datastore/Migration/Framework/NzbDroneMigrationBase.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework } } - public ISQLiteAlter SQLiteAlter { get; private set; } + protected ISQLiteAlter SQLiteAlter { get; private set; } public override void Down() { diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 94521c8d5..266de4463 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Threading; using FluentAssertions; using Moq; using NLog; @@ -42,6 +43,9 @@ namespace NzbDrone.Test.Common public abstract class TestBase : LoggingTest { + + private static readonly Random _random = new Random(); + private AutoMoqer _mocker; protected AutoMoqer Mocker { @@ -58,6 +62,15 @@ namespace NzbDrone.Test.Common protected Mock MockedRestProvider { get; private set; } + protected int RandomNumber + { + get + { + Thread.Sleep(1); + return _random.Next(0, int.MaxValue); + } + } + private string VirtualPath { get