fixed broken tests

pull/3113/head
kay.one 11 years ago
parent 16c9232b12
commit c90a96c2e0

@ -7,6 +7,7 @@ using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Rest; using NzbDrone.Core.Rest;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Categories; using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.MetadataSourceTests namespace NzbDrone.Core.Test.MetadataSourceTests
@ -51,6 +52,8 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
public void getting_details_of_invalid_series() public void getting_details_of_invalid_series()
{ {
Assert.Throws<RestException>(() => Subject.GetSeriesInfo(Int32.MaxValue)); Assert.Throws<RestException>(() => Subject.GetSeriesInfo(Int32.MaxValue));
ExceptionVerification.ExpectedWarns(1);
} }
private void ValidateSeries(Series series) private void ValidateSeries(Series series)

@ -20,14 +20,18 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
{ {
_monitoredSeries = Builder<Series>.CreateNew() _monitoredSeries = Builder<Series>.CreateNew()
.With(s => s.Id = 0) .With(s => s.Id = 0)
.With(s => s.TvRageId = RandomNumber)
.With(s => s.Runtime = 30) .With(s => s.Runtime = 30)
.With(s => s.Monitored = true) .With(s => s.Monitored = true)
.With(s => s.TitleSlug = "Title3")
.Build(); .Build();
_unmonitoredSeries = Builder<Series>.CreateNew() _unmonitoredSeries = Builder<Series>.CreateNew()
.With(s => s.Id = 0) .With(s => s.Id = 0)
.With(s => s.TvdbId = RandomNumber)
.With(s => s.Runtime = 30) .With(s => s.Runtime = 30)
.With(s => s.Monitored = false) .With(s => s.Monitored = false)
.With(s => s.TitleSlug = "Title2")
.Build(); .Build();
_monitoredSeries.Id = Db.Insert(_monitoredSeries).Id; _monitoredSeries.Id = Db.Insert(_monitoredSeries).Id;
@ -44,6 +48,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
var monitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3) var monitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
.All() .All()
.With(e => e.Id = 0) .With(e => e.Id = 0)
.With(e => e.TvDbEpisodeId = RandomNumber)
.With(e => e.SeriesId = _monitoredSeries.Id) .With(e => e.SeriesId = _monitoredSeries.Id)
.With(e => e.EpisodeFileId = 0) .With(e => e.EpisodeFileId = 0)
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
@ -57,6 +62,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
var unmonitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3) var unmonitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
.All() .All()
.With(e => e.Id = 0) .With(e => e.Id = 0)
.With(e => e.TvDbEpisodeId = RandomNumber)
.With(e => e.SeriesId = _unmonitoredSeries.Id) .With(e => e.SeriesId = _unmonitoredSeries.Id)
.With(e => e.EpisodeFileId = 0) .With(e => e.EpisodeFileId = 0)
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5)) .With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
@ -67,6 +73,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
.With(e => e.SeasonNumber = 0) .With(e => e.SeasonNumber = 0)
.Build(); .Build();
Db.InsertMany(monitoredSeriesEpisodes); Db.InsertMany(monitoredSeriesEpisodes);
Db.InsertMany(unmonitoredSeriesEpisodes); Db.InsertMany(unmonitoredSeriesEpisodes);
} }

@ -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() public override void Down()
{ {

@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Threading;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NLog; using NLog;
@ -42,6 +43,9 @@ namespace NzbDrone.Test.Common
public abstract class TestBase : LoggingTest public abstract class TestBase : LoggingTest
{ {
private static readonly Random _random = new Random();
private AutoMoqer _mocker; private AutoMoqer _mocker;
protected AutoMoqer Mocker protected AutoMoqer Mocker
{ {
@ -58,6 +62,15 @@ namespace NzbDrone.Test.Common
protected Mock<RestProvider> MockedRestProvider { get; private set; } protected Mock<RestProvider> MockedRestProvider { get; private set; }
protected int RandomNumber
{
get
{
Thread.Sleep(1);
return _random.Next(0, int.MaxValue);
}
}
private string VirtualPath private string VirtualPath
{ {
get get

Loading…
Cancel
Save