Test for HistoryProvider.AllItemsWithRelationships

This commit is contained in:
Mark McDowall 2011-06-19 17:02:10 -07:00
parent 0972c956b8
commit 63a2664d8a
1 changed files with 33 additions and 3 deletions

View File

@ -29,7 +29,6 @@ namespace NzbDrone.Core.Test
db.InsertMany(historyItem);
//Act
var result = mocker.Resolve<HistoryProvider>().AllItems();
@ -37,6 +36,39 @@ namespace NzbDrone.Core.Test
result.Should().HaveSameCount(historyItem);
}
[Test]
public void AllItemsWithRelationships()
{
//Setup
var seriesOne = Builder<Series>.CreateNew().With(s => s.SeriesId = 12345).Build();
var seriesTwo = Builder<Series>.CreateNew().With(s => s.SeriesId = 54321).Build();
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
var historyItems = Builder<History>.CreateListOfSize(10).WhereTheFirst(5).Have(h => h.SeriesId = seriesOne.SeriesId).WhereTheLast(5).Have(h => h.SeriesId = seriesTwo.SeriesId).Build();
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
db.InsertMany(historyItems);
db.InsertMany(episodes);
db.Insert(seriesOne);
db.Insert(seriesTwo);
//Act
var result = mocker.Resolve<HistoryProvider>().AllItemsWithRelationships();
//Assert
result.Should().HaveSameCount(historyItems);
foreach (var history in result)
{
Assert.NotNull(history.Episode);
Assert.That(!String.IsNullOrEmpty(history.SeriesTitle));
}
}
[Test]
public void PurgeItem()
{
@ -157,7 +189,5 @@ namespace NzbDrone.Core.Test
Assert.AreEqual(history.Quality, storedHistory.First().Quality);
Assert.AreEqual(history.IsProper, storedHistory.First().IsProper);
}
}
}