2011-06-18 01:01:09 +02:00
|
|
|
// ReSharper disable RedundantUsingDirective
|
2011-10-21 01:42:17 +02:00
|
|
|
|
2011-06-18 01:01:09 +02:00
|
|
|
using System;
|
2011-06-20 05:21:54 +02:00
|
|
|
using System.Collections.Generic;
|
2011-09-29 02:20:29 +02:00
|
|
|
using System.Linq;
|
2011-11-14 01:22:18 +01:00
|
|
|
|
2011-06-18 01:01:09 +02:00
|
|
|
using FizzWare.NBuilder;
|
2011-06-20 05:21:54 +02:00
|
|
|
using FluentAssertions;
|
2011-06-18 01:01:09 +02:00
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 01:22:18 +01:00
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-06-18 01:01:09 +02:00
|
|
|
|
2011-10-21 01:42:17 +02:00
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
2011-06-18 01:01:09 +02:00
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 08:27:16 +01:00
|
|
|
public class UpcomingEpisodesProviderTest : CoreTest
|
2011-06-18 01:01:09 +02:00
|
|
|
{
|
2011-09-29 02:20:29 +02:00
|
|
|
private IList<Episode> episodes;
|
2011-06-20 05:21:54 +02:00
|
|
|
private Series series;
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
[SetUp]
|
2011-10-24 07:54:09 +02:00
|
|
|
public void Setup()
|
2011-06-18 01:01:09 +02:00
|
|
|
{
|
2011-09-29 02:20:29 +02:00
|
|
|
episodes = Builder<Episode>.CreateListOfSize(6)
|
2011-10-18 23:46:06 +02:00
|
|
|
.All()
|
|
|
|
.With(e => e.SeriesId = 1)
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
.TheFirst(1)
|
2011-10-23 07:39:14 +02:00
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.AirDate = DateTime.Today)
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(2))
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(7))
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(9))
|
2011-06-18 01:01:09 +02:00
|
|
|
.Build();
|
|
|
|
|
2011-06-20 05:21:54 +02:00
|
|
|
series = Builder<Series>.CreateNew().With(s => s.SeriesId = 1).Build();
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Yesterday()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
2011-09-29 02:20:29 +02:00
|
|
|
database.InsertMany(episodes);
|
2011-06-20 05:21:54 +02:00
|
|
|
database.Insert(series);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Assert
|
2011-09-29 02:20:29 +02:00
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).First().Title);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Today()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
2011-09-29 02:20:29 +02:00
|
|
|
database.InsertMany(episodes);
|
2011-06-20 05:21:54 +02:00
|
|
|
database.Insert(series);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Assert
|
2011-09-29 02:20:29 +02:00
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today).First().Title);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Tomorrow()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
2011-09-29 02:20:29 +02:00
|
|
|
database.InsertMany(episodes);
|
2011-06-20 05:21:54 +02:00
|
|
|
database.Insert(series);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Assert
|
2011-09-29 02:20:29 +02:00
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.First().Title.Should().Be(episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).First().Title);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Week()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
2011-09-29 02:20:29 +02:00
|
|
|
database.InsertMany(episodes);
|
2011-06-20 05:21:54 +02:00
|
|
|
database.Insert(series);
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
|
2011-06-18 01:01:09 +02:00
|
|
|
|
|
|
|
//Assert
|
2011-09-29 02:20:29 +02:00
|
|
|
result.Should().HaveCount(2);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
result.Last().Series.Should().NotBeNull();
|
|
|
|
result.Last().Series.SeriesId.Should().NotBe(0);
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Yesterday_skip_ingored()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).Single().Ignored = true;
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().BeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Today_skip_ingored()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
episodes.Where(e => e.AirDate == DateTime.Today).Single().Ignored = true;
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().BeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Tomorrow_skip_ingored()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).Single().Ignored = true;
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().BeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get_Week_skip_ingored()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-11-23 06:58:26 +01:00
|
|
|
var database = TestDbHelper.GetEmptyDatabase();
|
2011-12-15 05:15:53 +01:00
|
|
|
|
|
|
|
Mocker.SetConstant(database);
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(2)).Single().Ignored = true;
|
|
|
|
|
|
|
|
database.InsertMany(episodes);
|
|
|
|
database.Insert(series);
|
|
|
|
|
|
|
|
//Act
|
2011-12-15 05:15:53 +01:00
|
|
|
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
|
2011-10-04 01:53:21 +02:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.First().Series.Should().NotBeNull();
|
|
|
|
result.First().Series.SeriesId.Should().NotBe(0);
|
|
|
|
}
|
2011-06-18 01:01:09 +02:00
|
|
|
}
|
|
|
|
}
|