UpcomingEpisodes will not show ignored episodes.

pull/3113/head
Mark McDowall 13 years ago
parent 7db08a10ec
commit 2cafedb1aa

@ -25,6 +25,7 @@ namespace NzbDrone.Core.Test
episodes = Builder<Episode>.CreateListOfSize(6)
.WhereAll()
.Have(e => e.SeriesId = 1)
.Have(e => e.Ignored = false)
.WhereTheFirst(1)
.Has(e => e.AirDate = DateTime.Today.AddDays(-1))
.AndTheNext(1)
@ -128,5 +129,87 @@ namespace NzbDrone.Core.Test
result.Last().Series.Should().NotBeNull();
result.Last().Series.SeriesId.Should().NotBe(0);
}
[Test]
public void Get_Yesterday_skip_ingored()
{
//Setup
var database = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).Single().Ignored = true;
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
//Assert
result.Should().BeEmpty();
}
[Test]
public void Get_Today_skip_ingored()
{
//Setup
var database = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today).Single().Ignored = true;
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Today();
//Assert
result.Should().BeEmpty();
}
[Test]
public void Get_Tomorrow_skip_ingored()
{
//Setup
var database = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).Single().Ignored = true;
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
//Assert
result.Should().BeEmpty();
}
[Test]
public void Get_Week_skip_ingored()
{
//Setup
var database = MockLib.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(2)).Single().Ignored = true;
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert
result.Should().HaveCount(1);
result.First().Series.Should().NotBeNull();
result.First().Series.SeriesId.Should().NotBe(0);
}
}
}

@ -22,7 +22,7 @@ namespace NzbDrone.Core.Providers
{
var allEps = _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1",
WHERE Ignored = 0 AND AirDate BETWEEN @0 AND @1",
DateTime.Today.AddDays(-1), DateTime.Today.AddDays(8));
var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList();
@ -36,28 +36,28 @@ namespace NzbDrone.Core.Providers
{
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(-1));
WHERE Ignored = 0 AND AirDate = @0", DateTime.Today.AddDays(-1));
}
public virtual List<Episode> Today()
{
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today);
WHERE Ignored = 0 AND AirDate = @0", DateTime.Today);
}
public virtual List<Episode> Tomorrow()
{
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(1));
WHERE Ignored = 0 AND AirDate = @0", DateTime.Today.AddDays(1));
}
public virtual List<Episode> Week()
{
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
WHERE Ignored = 0 AND AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
}
}
}
Loading…
Cancel
Save