1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 09:47:39 +00:00

Updated tests to for Upcoming Provider to make sure a series is returned.

This commit is contained in:
Mark McDowall 2011-06-19 20:21:54 -07:00
parent 86ab26e2d9
commit 5a99d374d9

View file

@ -1,7 +1,9 @@
// ReSharper disable RedundantUsingDirective // ReSharper disable RedundantUsingDirective
using System; using System;
using System.Collections.Generic;
using AutoMoq; using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -18,6 +20,7 @@ namespace NzbDrone.Core.Test
private Episode tomorrow; private Episode tomorrow;
private Episode twoDays; private Episode twoDays;
private Episode sevenDays; private Episode sevenDays;
private Series series;
[SetUp] [SetUp]
public new void Setup() public new void Setup()
@ -25,33 +28,41 @@ namespace NzbDrone.Core.Test
yesterday = Builder<Episode>.CreateNew() yesterday = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(-1)) .With(c => c.AirDate = DateTime.Today.AddDays(-1))
.With(c => c.Title = "Yesterday") .With(c => c.Title = "Yesterday")
.With(c => c.SeriesId = 1)
.Build(); .Build();
today = Builder<Episode>.CreateNew() today = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today) .With(c => c.AirDate = DateTime.Today)
.With(c => c.Title = "Today") .With(c => c.Title = "Today")
.With(c => c.SeriesId = 1)
.Build(); .Build();
tomorrow = Builder<Episode>.CreateNew() tomorrow = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(1)) .With(c => c.AirDate = DateTime.Today.AddDays(1))
.With(c => c.Title = "Tomorrow") .With(c => c.Title = "Tomorrow")
.With(c => c.SeriesId = 1)
.Build(); .Build();
twoDays = Builder<Episode>.CreateNew() twoDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(2)) .With(c => c.AirDate = DateTime.Today.AddDays(2))
.With(c => c.Title = "Two Days") .With(c => c.Title = "Two Days")
.With(c => c.SeriesId = 1)
.Build(); .Build();
sevenDays = Builder<Episode>.CreateNew() sevenDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(7)) .With(c => c.AirDate = DateTime.Today.AddDays(7))
.With(c => c.Title = "Seven Days") .With(c => c.Title = "Seven Days")
.With(c => c.SeriesId = 1)
.Build(); .Build();
sevenDays = Builder<Episode>.CreateNew() sevenDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(8)) .With(c => c.AirDate = DateTime.Today.AddDays(8))
.With(c => c.Title = "Eight Days") .With(c => c.Title = "Eight Days")
.With(c => c.SeriesId = 1)
.Build(); .Build();
series = Builder<Series>.CreateNew().With(s => s.SeriesId = 1).Build();
base.Setup(); base.Setup();
} }
@ -68,6 +79,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow); database.Insert(tomorrow);
database.Insert(twoDays); database.Insert(twoDays);
database.Insert(sevenDays); database.Insert(sevenDays);
database.Insert(series);
//Act //Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday(); var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
@ -75,6 +87,8 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result.Count);
Assert.AreEqual(yesterday.Title, result[0].Title); Assert.AreEqual(yesterday.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
} }
[Test] [Test]
@ -90,6 +104,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow); database.Insert(tomorrow);
database.Insert(twoDays); database.Insert(twoDays);
database.Insert(sevenDays); database.Insert(sevenDays);
database.Insert(series);
//Act //Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Today(); var result = mocker.Resolve<UpcomingEpisodesProvider>().Today();
@ -97,6 +112,8 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result.Count);
Assert.AreEqual(today.Title, result[0].Title); Assert.AreEqual(today.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
} }
[Test] [Test]
@ -112,6 +129,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow); database.Insert(tomorrow);
database.Insert(twoDays); database.Insert(twoDays);
database.Insert(sevenDays); database.Insert(sevenDays);
database.Insert(series);
//Act //Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow(); var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
@ -119,6 +137,8 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result.Count);
Assert.AreEqual(tomorrow.Title, result[0].Title); Assert.AreEqual(tomorrow.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
} }
[Test] [Test]
@ -134,12 +154,17 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow); database.Insert(tomorrow);
database.Insert(twoDays); database.Insert(twoDays);
database.Insert(sevenDays); database.Insert(sevenDays);
database.Insert(series);
//Act //Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Week(); var result = mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert //Assert
Assert.AreEqual(2, result.Count); Assert.AreEqual(2, result.Count);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
result[1].Series.Should().NotBeNull();
result[1].Series.SeriesId.Should().NotBe(0);
} }
} }
} }