Converted jobs to dynamic

This commit is contained in:
Mark McDowall 2012-09-10 12:04:17 -07:00
commit a4dde81ceb
42 changed files with 166 additions and 170 deletions

View file

@ -39,23 +39,23 @@ namespace NzbDrone.Core.Test.JobTests
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0}))
.Callback(() => series[0].LastDiskSync = DateTime.Now);
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }))
.Callback(() => series[1].LastDiskSync = DateTime.Now);
Mocker.GetMock<BannerDownloadJob>()
.Setup(j => j.Start(notification, It.IsAny<int>(), 0));
.Setup(j => j.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = 0 }));
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }))
.Callback(() => series[0].LastInfoSync = DateTime.Now);
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }))
.Callback(() => series[1].LastInfoSync = DateTime.Now);
Mocker.GetMock<SeriesProvider>()
@ -68,16 +68,14 @@ namespace NzbDrone.Core.Test.JobTests
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
//Act
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }), Times.Once());
}
@ -103,19 +101,19 @@ namespace NzbDrone.Core.Test.JobTests
.Returns(series);
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }))
.Callback(() => series[0].LastInfoSync = DateTime.Now);
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }))
.Throws(new InvalidOperationException());
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Setup(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }))
.Callback(() => series[0].LastDiskSync = DateTime.Now);
Mocker.GetMock<BannerDownloadJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0));
.Setup(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }));
Mocker.GetMock<SeriesProvider>()
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
@ -124,15 +122,15 @@ namespace NzbDrone.Core.Test.JobTests
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
//Act
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0 }), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, new { SeriesId = series[1].SeriesId, SeasonNumber = 0 }), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, new { SeriesId = series[0].SeriesId, SeasonNumber = 0}), Times.Once());
ExceptionVerification.ExpectedErrors(1);