|
|
@ -12,6 +12,7 @@ using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.JobTests
|
|
|
|
namespace NzbDrone.Core.Test.JobTests
|
|
|
@ -65,23 +66,19 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
.With(e => e.Series = series)
|
|
|
|
.With(e => e.Series = series)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
|
|
|
.Setup(s => s.Start(notification, new { EpisodeId = 1 }));
|
|
|
|
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
//Act
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
Times.Never());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }),
|
|
|
|
|
|
|
|
Times.Once());
|
|
|
|
Times.Once());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -101,23 +98,16 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
.With(e => e.Series = series)
|
|
|
|
.With(e => e.Series = series)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
|
|
|
|
|
|
|
.Setup(s => s.Start(notification, new { EpisodeId = It.IsAny<int>()})).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
//Act
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
Times.Never());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }),
|
|
|
|
|
|
|
|
Times.Exactly(episodes.Count));
|
|
|
|
Times.Exactly(episodes.Count));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -138,15 +128,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
|
|
|
|
|
|
|
.Setup(s => s.Start(notification, new { EpisodeId = It.IsAny<int>() })).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
|
|
|
|
|
|
|
|
|
|
@ -154,10 +140,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
Times.Never());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }),
|
|
|
|
|
|
|
|
Times.Exactly(episodes.Count));
|
|
|
|
Times.Exactly(episodes.Count));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -179,15 +162,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<SeasonSearchJob>()
|
|
|
|
|
|
|
|
.Setup(s => s.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() })).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
|
|
|
|
|
|
|
|
|
|
@ -195,11 +174,9 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
|
|
|
|
|
|
|
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
|
|
|
Times.Once());
|
|
|
|
Times.Once());
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }),
|
|
|
|
|
|
|
|
Times.Never());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -227,18 +204,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
.With(e => e.Series = series2)
|
|
|
|
.With(e => e.Series = series2)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
WithEnableBacklogSearching();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<SeasonSearchJob>()
|
|
|
|
|
|
|
|
.Setup(s => s.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() })).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>()
|
|
|
|
|
|
|
|
.Setup(s => s.Start(notification, new { EpisodeId = It.IsAny<int>() })).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
|
|
|
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
|
|
|
|
|
|
|
|
|
|
@ -246,10 +216,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
Mocker.Resolve<BacklogSearchJob>().Start(notification, null);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
|
|
|
|
|
|
|
|
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
|
|
|
|
Times.Once());
|
|
|
|
Times.Once());
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }),
|
|
|
|
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
|
|
|
|
Times.Exactly(5));
|
|
|
|
Times.Exactly(5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|