Updated tests for UpcomingProvider. #ND-45 fixed

This commit is contained in:
Mark McDowall 2012-05-17 18:23:32 -07:00
parent ac2f3399f0
commit 3fdfa69b94
2 changed files with 8 additions and 98 deletions

View File

@ -64,97 +64,27 @@ namespace NzbDrone.Core.Test.ProviderTests
}
[Test]
public void Get_Yesterday()
public void Get_UpcomingEpisodes()
{
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes();
//Assert
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_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().HaveCount(5);
result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.SeriesId);
}
[Test]
public void Get_Yesterday_should_skip_ingored()
public void Get_UpcomingEpisodes_should_skip_ingored()
{
WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday().Should().BeEmpty();
Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
}
[Test]
public void Get_Today_should_skip_ingored()
{
WithIgnoredEpisodes();
Mocker.Resolve<UpcomingEpisodesProvider>().Today().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()
public void Get_UpcomingEpisodes_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]
public void Get_Week_should_skip_unmonitored_series()
{
WithIgnoredSeries();
Mocker.Resolve<UpcomingEpisodesProvider>().Week().Should().BeEmpty();
Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
}
}
}

View File

@ -18,27 +18,7 @@ namespace NzbDrone.Core.Providers
_database = database;
}
public virtual List<Episode> Yesterday()
{
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()
public virtual List<Episode> UpcomingEpisodes()
{
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId