@ -19,6 +19,14 @@ namespace NzbDrone.Core.Test.JobTests
// ReSharper disable InconsistentNaming
public class BannerDownloadJobTest : TestBase
{
[SetUp]
public void Setup ( )
{
WithStrictMocker ( ) ;
WithTempAsStartUpPath ( ) ;
}
[Test]
public void BannerDownload_all ( )
{
@ -26,28 +34,25 @@ namespace NzbDrone.Core.Test.JobTests
var fakeSeries = Builder < Series > . CreateListOfSize ( 10 )
. Build ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
mocker . Resolve < EnviromentProvider > ( ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < SeriesProvider > ( )
Mocker . GetMock < SeriesProvider > ( )
. Setup ( c = > c . GetAllSeries ( ) )
. Returns ( fakeSeries ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) ;
m ocker. GetMock < DiskProvider > ( )
M ocker. GetMock < DiskProvider > ( )
. Setup ( S = > S . CreateDirectory ( It . IsAny < string > ( ) ) )
. Returns ( "" ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Exactly ( fakeSeries . Count ) ) ;
}
@ -60,28 +65,25 @@ namespace NzbDrone.Core.Test.JobTests
. With ( s = > s . BannerUrl = null )
. Build ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
mocker . Resolve < EnviromentProvider > ( ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < SeriesProvider > ( )
Mocker . GetMock < SeriesProvider > ( )
. Setup ( c = > c . GetAllSeries ( ) )
. Returns ( fakeSeries ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ) ;
m ocker. GetMock < DiskProvider > ( )
M ocker. GetMock < DiskProvider > ( )
. Setup ( S = > S . CreateDirectory ( It . IsAny < string > ( ) ) )
. Returns ( "" ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Exactly ( 8 ) ) ;
}
@ -92,67 +94,64 @@ namespace NzbDrone.Core.Test.JobTests
var fakeSeries = Builder < Series > . CreateListOfSize ( 10 )
. Build ( ) ;
var pathProvider = Mocker . Resolve < PathProvider > ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
mocker . Resolve < EnviromentProvider > ( ) ;
var pathProvider = Mocker . Resolve < PathProvider > ( ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < SeriesProvider > ( )
M ocker. GetMock < SeriesProvider > ( )
. Setup ( c = > c . GetAllSeries ( ) )
. Returns ( fakeSeries ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "1.jpg" ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "2.jpg" ) ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "3.jpg" ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "4.jpg" ) ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "5.jpg" ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "6.jpg" ) ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "7.jpg" ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "8.jpg" ) ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "9.jpg" ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , Path . Combine ( pathProvider . BannerPath , "10.jpg" ) ) ) ;
m ocker. GetMock < DiskProvider > ( )
M ocker. GetMock < DiskProvider > ( )
. Setup ( S = > S . CreateDirectory ( It . IsAny < string > ( ) ) )
. Returns ( "" ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Exactly ( fakeSeries . Count ) ) ;
}
@ -163,29 +162,26 @@ namespace NzbDrone.Core.Test.JobTests
var fakeSeries = Builder < Series > . CreateListOfSize ( 10 )
. Build ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
mocker . Resolve < EnviromentProvider > ( ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < SeriesProvider > ( )
Mocker . GetMock < SeriesProvider > ( )
. Setup ( c = > c . GetAllSeries ( ) )
. Returns ( fakeSeries ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < DiskProvider > ( )
M ocker. GetMock < DiskProvider > ( )
. Setup ( S = > S . CreateDirectory ( It . IsAny < string > ( ) ) )
. Returns ( "" ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 0 , 0 ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Exactly ( fakeSeries . Count ) ) ;
}
@ -197,29 +193,26 @@ namespace NzbDrone.Core.Test.JobTests
. With ( s = > s . SeriesId = 1 )
. Build ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
mocker . Resolve < EnviromentProvider > ( ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < SeriesProvider > ( )
Mocker . GetMock < SeriesProvider > ( )
. Setup ( c = > c . GetSeries ( 1 ) )
. Returns ( fakeSeries ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) )
. Throws ( new WebException ( ) ) ;
m ocker. GetMock < DiskProvider > ( )
M ocker. GetMock < DiskProvider > ( )
. Setup ( S = > S . CreateDirectory ( It . IsAny < string > ( ) ) )
. Returns ( "" ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 1 , 0 ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . Start ( notification , 1 , 0 ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Once ( ) ) ;
}
@ -231,20 +224,18 @@ namespace NzbDrone.Core.Test.JobTests
. With ( s = > s . SeriesId = 1 )
. Build ( ) ;
var mocker = new AutoMoqer ( MockBehavior . Strict ) ;
var notification = new ProgressNotification ( "Banner Download" ) ;
m ocker. GetMock < HttpProvider > ( )
M ocker. GetMock < HttpProvider > ( )
. Setup ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) )
. Throws ( new WebException ( ) ) ;
//Act
m ocker. Resolve < BannerDownloadJob > ( ) . DownloadBanner ( notification , fakeSeries ) ;
M ocker. Resolve < BannerDownloadJob > ( ) . DownloadBanner ( notification , fakeSeries ) ;
//Assert
m ocker. VerifyAllMocks ( ) ;
m ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
M ocker. VerifyAllMocks ( ) ;
M ocker. GetMock < HttpProvider > ( ) . Verify ( s = > s . DownloadFile ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) ,
Times . Once ( ) ) ;
}
}