Updated tests for UpcomingProvider. #ND-45 fixed

pull/4/head
Mark McDowall 13 years ago
parent ac2f3399f0
commit 3fdfa69b94

@ -64,97 +64,27 @@ namespace NzbDrone.Core.Test.ProviderTests
} }
[Test] [Test]
public void Get_Yesterday() public void Get_UpcomingEpisodes()
{ {
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday(); var result = Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes();
//Assert //Assert
result.Should().NotBeEmpty(); result.Should().HaveCount(5);
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.AddDays(-1).Date);
result.First().Series.Should().NotBeNull();
result.First().Series.SeriesId.Should().Be(series.SeriesId);
}
[Test]
public void Get_Today()
{
//Act
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.Date);
result.First().Series.Should().NotBeNull();
result.First().Series.SeriesId.Should().Be(series.SeriesId);
}
[Test]
public void Get_Tomorrow()
{
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.AddDays(1).Date);
result.First().Series.Should().NotBeNull();
result.First().Series.SeriesId.Should().Be(series.SeriesId);
}
[Test]
public void Get_Week()
{
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert
result.Should().HaveCount(2);
result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.SeriesId); result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.SeriesId);
} }
[Test] [Test]
public void Get_Yesterday_should_skip_ingored() public void Get_UpcomingEpisodes_should_skip_ingored()
{
WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday().Should().BeEmpty();
}
[Test]
public void Get_Today_should_skip_ingored()
{ {
WithIgnoredEpisodes(); WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Today().Should().BeEmpty(); Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
}
[Test]
public void Get_Tomorrow_should_skip_ingored()
{
WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow().Should().BeEmpty();
}
[Test]
public void Get_Week_should_skip_ingored()
{
WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Week().Should().BeEmpty();
}
[Test]
public void Get_Today_should_skip_unmonitored_series()
{
WithIgnoredSeries();
Mocker.Resolve<UpcomingEpisodesProvider>().Today().Should().BeEmpty();
}
[Test]
public void Get_Tomoroww_should_skip_unmonitored_series()
{
WithIgnoredSeries();
Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow().Should().BeEmpty();
} }
[Test] [Test]
public void Get_Week_should_skip_unmonitored_series() public void Get_UpcomingEpisodes_should_skip_unmonitored_series()
{ {
WithIgnoredSeries(); WithIgnoredSeries();
Mocker.Resolve<UpcomingEpisodesProvider>().Week().Should().BeEmpty(); Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
} }
} }
} }

@ -18,27 +18,7 @@ namespace NzbDrone.Core.Providers
_database = database; _database = database;
} }
public virtual List<Episode> Yesterday() public virtual List<Episode> UpcomingEpisodes()
{
return RecentEpisodes().Where(c => c.AirDate.Value.Date == DateTime.Now.Date.AddDays(-1)).ToList();
}
public virtual List<Episode> Today()
{
return RecentEpisodes().Where(c => c.AirDate.Value.Date == DateTime.Now.Date).ToList();
}
public virtual List<Episode> Tomorrow()
{
return RecentEpisodes().Where(c => c.AirDate.Value.Date == DateTime.Now.Date.AddDays(1)).ToList();
}
public virtual List<Episode> Week()
{
return RecentEpisodes().Where(c => c.AirDate >= DateTime.Today.AddDays(2).Date).ToList();
}
public virtual List<Episode> RecentEpisodes()
{ {
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId

Loading…
Cancel
Save