|
|
@ -1,21 +1,18 @@
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
|
|
|
public class UpcomingEpisodesProviderTest : CoreTest
|
|
|
|
public class UpcomingEpisodesProviderTest : CoreTest
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private IList<Episode> episodes;
|
|
|
|
private IList<Episode> episodes;
|
|
|
@ -24,6 +21,8 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
WithRealDb();
|
|
|
|
|
|
|
|
|
|
|
|
episodes = Builder<Episode>.CreateListOfSize(6)
|
|
|
|
episodes = Builder<Episode>.CreateListOfSize(6)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.SeriesId = 1)
|
|
|
|
.With(e => e.SeriesId = 1)
|
|
|
@ -42,174 +41,120 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(9))
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(9))
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
series = Builder<Series>.CreateNew().With(s => s.SeriesId = 1).Build();
|
|
|
|
series = Builder<Series>.CreateNew()
|
|
|
|
|
|
|
|
.With(s => s.SeriesId = 1)
|
|
|
|
|
|
|
|
.And(c => c.Monitored = true)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.InsertMany(episodes);
|
|
|
|
|
|
|
|
Db.Insert(series);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
private void WithIgnoredEpisodes()
|
|
|
|
public void Get_Yesterday()
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
episodes.ToList().ForEach(c => c.Ignored = true);
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
Db.UpdateMany(episodes);
|
|
|
|
|
|
|
|
}
|
|
|
|
Mocker.SetConstant(database);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
private void WithIgnoredSeries()
|
|
|
|
database.Insert(series);
|
|
|
|
{
|
|
|
|
|
|
|
|
series.Monitored = false;
|
|
|
|
|
|
|
|
Db.Update(series);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void Get_Yesterday()
|
|
|
|
|
|
|
|
{
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).First().Title);
|
|
|
|
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.AddDays(-1).Date);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
result.First().Series.SeriesId.Should().Be(series.SeriesId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Get_Today()
|
|
|
|
public void Get_Today()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
//Act
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.Date);
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today).First().Title);
|
|
|
|
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
result.First().Series.SeriesId.Should().Be(series.SeriesId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Get_Tomorrow()
|
|
|
|
public void Get_Tomorrow()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().NotBeEmpty();
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.Should().OnlyContain(c => c.AirDate.Value.Date == DateTime.Today.AddDays(1).Date);
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).First().Title);
|
|
|
|
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
result.First().Series.SeriesId.Should().Be(series.SeriesId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Get_Week()
|
|
|
|
public void Get_Week()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
result.Should().HaveCount(2);
|
|
|
|
result.Should().HaveCount(2);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.SeriesId);
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
|
|
|
|
result.Last().Series.Should().NotBeNull();
|
|
|
|
|
|
|
|
result.Last().Series.SeriesId.Should().NotBe(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Get_Yesterday_skip_ingored()
|
|
|
|
public void Get_Yesterday_should_skip_ingored()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
WithIgnoredEpisodes();
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday().Should().BeEmpty();
|
|
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
[Test]
|
|
|
|
public void Get_Today_skip_ingored()
|
|
|
|
public void Get_Today_should_skip_ingored()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
WithIgnoredEpisodes();
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Today().Should().BeEmpty();
|
|
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
[Test]
|
|
|
|
public void Get_Tomorrow_skip_ingored()
|
|
|
|
public void Get_Tomorrow_should_skip_ingored()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
WithIgnoredEpisodes();
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow().Should().BeEmpty();
|
|
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
[Test]
|
|
|
|
public void Get_Week_skip_ingored()
|
|
|
|
public void Get_Week_should_skip_ingored()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
WithIgnoredEpisodes();
|
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Week().Should().BeEmpty();
|
|
|
|
|
|
|
|
}
|
|
|
|
Mocker.SetConstant(database);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(2)).Single().Ignored = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
[Test]
|
|
|
|
database.Insert(series);
|
|
|
|
public void Get_Today_should_skip_unmonitored_series()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
WithIgnoredSeries();
|
|
|
|
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Today().Should().BeEmpty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
[Test]
|
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
|
|
|
|
public void Get_Tomoroww_should_skip_unmonitored_series()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
WithIgnoredSeries();
|
|
|
|
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow().Should().BeEmpty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
[Test]
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
public void Get_Week_should_skip_unmonitored_series()
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
{
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
WithIgnoredSeries();
|
|
|
|
|
|
|
|
Mocker.Resolve<UpcomingEpisodesProvider>().Week().Should().BeEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|