sonarr-repo-only/NzbDrone.Core.Test/MediaFileProviderTests.cs

78 lines
2.1 KiB
C#
Raw Normal View History

2011-05-22 16:53:21 +00:00
// ReSharper disable RedundantUsingDirective
using System;
2011-05-18 05:32:23 +00:00
using System.Collections.Generic;
using System.IO;
2011-05-18 05:32:23 +00:00
using System.Linq;
2011-06-18 02:00:44 +00:00
using System.Linq.Expressions;
using AutoMoq;
using FizzWare.NBuilder;
2011-06-02 21:06:46 +00:00
using FluentAssertions;
using Moq;
2011-06-02 21:06:46 +00:00
using NUnit.Framework;
using NzbDrone.Core.Model;
2011-05-18 05:32:23 +00:00
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
2011-04-04 03:50:12 +00:00
using NzbDrone.Core.Providers.Core;
2011-05-18 05:32:23 +00:00
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class MediaFileProviderTests : TestBase
{
2011-06-21 05:44:01 +00:00
2011-05-18 05:32:23 +00:00
2011-06-20 02:33:43 +00:00
2011-05-18 05:32:23 +00:00
[Test]
public void get_series_files()
2011-05-18 05:32:23 +00:00
{
var firstSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.WhereAll().Have(s => s.SeriesId = 12).Build();
2011-05-18 05:32:23 +00:00
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.WhereAll().Have(s => s.SeriesId = 20).Build();
2011-05-18 05:32:23 +00:00
var mocker = new AutoMoqer();
var database = MockLib.GetEmptyDatabase(true);
foreach (var file in firstSeriesFiles)
database.Insert(file);
foreach (var file in secondSeriesFiles)
database.Insert(file);
mocker.SetConstant(database);
2011-06-02 21:06:46 +00:00
var result = mocker.Resolve<MediaFileProvider>().GetSeriesFiles(12);
2011-05-18 05:32:23 +00:00
result.Should().HaveSameCount(firstSeriesFiles);
2011-05-18 05:32:23 +00:00
}
[Test]
public void Scan_series_should_skip_series_with_no_episodes()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodeBySeries(12))
.Returns(new List<Episode>());
var series = Builder<Series>.CreateNew()
.With(s => s.SeriesId = 12).Build();
//Act
2011-06-20 03:04:08 +00:00
mocker.Resolve<DiskScanProvider>().Scan(series);
//Assert
mocker.VerifyAllMocks();
}
}
2011-04-10 02:44:01 +00:00
}