Merge branch 'master' of git://github.com/kayone/NzbDrone
This commit is contained in:
commit
7d1f0d2c08
|
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test
|
||||||
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||||
.With(e => e.Ignored = ignored)
|
.With(e => e.Ignored = ignored)
|
||||||
.With(e => e.EpisodeFileId = 0)
|
.With(e => e.EpisodeFileId = 0)
|
||||||
.With(e => e.GrabDate = DateTime.Now.AddDays(-1))
|
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
if (hasEpisodes)
|
if (hasEpisodes)
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.ServiceModel.Syndication;
|
||||||
|
using AutoMoq;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Model;
|
||||||
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
using NzbDrone.Core.Providers.Indexer;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Core.Repository.Quality;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
public class FluentTest : TestBase
|
||||||
|
{
|
||||||
|
[TestCase(null, "def", "def")]
|
||||||
|
[TestCase("", "def", "def")]
|
||||||
|
[TestCase("", 1, "1")]
|
||||||
|
[TestCase(null, "", "")]
|
||||||
|
[TestCase("actual", "def", "actual")]
|
||||||
|
public void WithDefault_success(string actual, object defaultValue, string result)
|
||||||
|
{
|
||||||
|
actual.WithDefault(defaultValue).Should().Be(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(ArgumentNullException))]
|
||||||
|
public void WithDefault_Fail()
|
||||||
|
{
|
||||||
|
"test".WithDefault(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,17 +23,6 @@ namespace NzbDrone.Core.Test.Framework
|
||||||
get { return new[] { "c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24" }; }
|
get { return new[] { "c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24" }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigProvider StandardConfig
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var mock = new Mock<ConfigProvider>();
|
|
||||||
mock.SetupGet(c => c.SeriesRoot).Returns("C:\\");
|
|
||||||
return mock.Object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
|
public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
|
||||||
{
|
{
|
||||||
Console.WriteLine("Creating an empty PetaPoco database");
|
Console.WriteLine("Creating an empty PetaPoco database");
|
||||||
|
@ -83,14 +72,5 @@ namespace NzbDrone.Core.Test.Framework
|
||||||
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IList<Episode> GetFakeEpisodes(int seriesId)
|
|
||||||
{
|
|
||||||
var epNumber = new SequentialGenerator<int>();
|
|
||||||
return Builder<Episode>.CreateListOfSize(10)
|
|
||||||
.WhereAll().Have(c => c.SeriesId = seriesId)
|
|
||||||
.WhereAll().Have(c => c.EpisodeNumber = epNumber.Generate())
|
|
||||||
.Build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -84,6 +84,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="FluentTest.cs" />
|
||||||
<Compile Include="LogProviderTest.cs" />
|
<Compile Include="LogProviderTest.cs" />
|
||||||
<Compile Include="UpcomingEpisodesProviderTest.cs" />
|
<Compile Include="UpcomingEpisodesProviderTest.cs" />
|
||||||
<Compile Include="MediaFileProvider_ImportNewDownloadTest.cs" />
|
<Compile Include="MediaFileProvider_ImportNewDownloadTest.cs" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// ReSharper disable RedundantUsingDirective
|
using System;
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AutoMoq;
|
using AutoMoq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
|
@ -15,11 +14,9 @@ using PetaPoco;
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
namespace NzbDrone.Core.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
public class SeriesProviderTest : TestBase
|
public class SeriesProviderTest : TestBase
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -130,10 +127,12 @@ namespace NzbDrone.Core.Test
|
||||||
var db = MockLib.GetEmptyDatabase();
|
var db = MockLib.GetEmptyDatabase();
|
||||||
mocker.SetConstant(db);
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.QualityProfileId = 1).Build();
|
var fakeSeries = Builder<Series>.CreateNew()
|
||||||
|
.With(c => c.QualityProfileId = 1)
|
||||||
|
.Build();
|
||||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||||
|
|
||||||
var id = db.Insert(fakeSeries);
|
db.Insert(fakeSeries);
|
||||||
db.Insert(fakeQuality);
|
db.Insert(fakeQuality);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -141,9 +140,10 @@ namespace NzbDrone.Core.Test
|
||||||
var series = mocker.Resolve<SeriesProvider>().GetSeries(1);
|
var series = mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId);
|
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId).EqualTo(fakeSeries);
|
||||||
series.QualityProfile.Should().NotBeNull();
|
series.QualityProfile.Should().NotBeNull();
|
||||||
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.AllowedString);
|
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.SonicAllowed).EqualTo(fakeQuality);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -239,8 +239,5 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.IsFalse(provider.IsMonitored(11));
|
Assert.IsFalse(provider.IsMonitored(11));
|
||||||
Assert.IsFalse(provider.IsMonitored(1));
|
Assert.IsFalse(provider.IsMonitored(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} |