mirror of https://github.com/Radarr/Radarr
Added NextAiring to Series (ResultColumn), which is used for Series/Index. Added tests and fixed broken tests after adding new property.
This commit is contained in:
parent
f014ddcfea
commit
6736afbeab
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
episode.EpisodeFile.Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
@ -769,7 +769,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
episode.EpisodeFile.Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
episode.EpisodeFile.Should().BeNull();
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
episode.EpisodeFile.Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
@ -840,7 +840,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount).EqualTo(fakeSeries);
|
||||
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
episode.EpisodeFile.Should().BeNull();
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test
|
|||
var series = mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||
|
||||
//Assert
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId).EqualTo(fakeSeries);
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.SonicAllowed).EqualTo(fakeQuality);
|
||||
|
||||
|
@ -475,5 +475,126 @@ namespace NzbDrone.Core.Test
|
|||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Today()
|
||||
{
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.WhereTheFirst(1)
|
||||
.Have(e => e.AirDate = DateTime.Today)
|
||||
.AndTheRemaining()
|
||||
.Have(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.Build();
|
||||
|
||||
db.Insert(fakeSeries);
|
||||
db.Insert(fakeQuality);
|
||||
db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<QualityProvider>();
|
||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday()
|
||||
{
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.WhereTheFirst(1)
|
||||
.Have(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.AndTheRemaining()
|
||||
.Have(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.Build();
|
||||
|
||||
db.Insert(fakeSeries);
|
||||
db.Insert(fakeQuality);
|
||||
db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<QualityProvider>();
|
||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today.AddDays(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Unknown()
|
||||
{
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.Have(e => e.AirDate = null)
|
||||
.Build();
|
||||
|
||||
db.Insert(fakeSeries);
|
||||
db.Insert(fakeQuality);
|
||||
db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<QualityProvider>();
|
||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().NotHaveValue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_1_month()
|
||||
{
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.WhereTheFirst(1)
|
||||
.Have(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.AndTheRemaining()
|
||||
.Have(e => e.AirDate = DateTime.Today.AddMonths(1))
|
||||
.Build();
|
||||
|
||||
db.Insert(fakeSeries);
|
||||
db.Insert(fakeQuality);
|
||||
db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
mocker.Resolve<QualityProvider>();
|
||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
|
||||
}
|
||||
}
|
||||
} |