1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 15:32:31 +01:00

fixed some tests, spelling issues.

This commit is contained in:
Keivan Beigi 2013-04-12 16:28:05 -07:00
parent 339dd5a1dd
commit 420756bb47
14 changed files with 79 additions and 120 deletions

View File

@ -33,6 +33,9 @@ namespace NzbDrone.Core.Test.InstrumentationTests
Mocker.Resolve<ILogRepository, LogRepository>();
Mocker.Resolve<DatabaseTarget>().Register();
LogManager.ReconfigExistingLoggers();
_logger = LogManager.GetCurrentClassLogger();
_loggerName = _logger.Name.Replace("NzbDrone.","");

View File

@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.JobTests
{
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
Mocker.GetMock<ConfigFileProvider>().SetupGet(c => c.Guid).Returns(_clientGuid);
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns(updatePackage);
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvailableUpdate(It.IsAny<Version>())).Returns(updatePackage);
}
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test]
public void when_no_updates_are_available_should_return_without_error_or_warnings()
{
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns((UpdatePackage)null);
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvailableUpdate(It.IsAny<Version>())).Returns((UpdatePackage)null);
StartUpdate();

View File

@ -178,7 +178,7 @@
<Compile Include="JobTests\TestJobs.cs" />
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetUpdateLogFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetAvailableUpdateFixture.cs" />
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetSceneTvdbMappingsFixture.cs" />
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
<Compile Include="Services\ParseErrorServiceFixture.cs" />

View File

@ -1,23 +1,16 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{

View File

@ -0,0 +1,55 @@
using System;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
class GetAvailableUpdateFixture : CoreTest<UpdateProvider>
{
private static readonly Version LatestTestVersion = new Version("0.6.0.3");
private const string LATEST_TEST_URL = "http://update.nzbdrone.com/_test/NzbDrone.master.0.6.0.3.zip";
private const string LATEST_TEST_FILE_NAME = "NzbDrone.master.0.6.0.3.zip";
[SetUp]
public void Setup()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.Resolve<HttpProvider>();
}
[TestCase("0.6.0.9")]
[TestCase("0.7.0.1")]
[TestCase("1.0.0.0")]
public void should_return_null_if_latest_is_lower_than_current_version(string currentVersion)
{
var updatePackage = Subject.GetAvailableUpdate(new Version(currentVersion));
updatePackage.Should().BeNull();
}
[Test]
public void should_return_null_if_latest_is_equal_to_current_version()
{
var updatePackage = Subject.GetAvailableUpdate(LatestTestVersion);
updatePackage.Should().BeNull();
}
[TestCase("0.0.0.0")]
[TestCase("0.0.0.1")]
[TestCase("0.0.10.10")]
public void should_return_update_if_latest_is_higher_than_current_version(string currentVersion)
{
var updatePackage = Subject.GetAvailableUpdate(new Version(currentVersion));
updatePackage.Should().NotBeNull();
updatePackage.Version.Should().Be(LatestTestVersion);
updatePackage.FileName.Should().BeEquivalentTo(LATEST_TEST_FILE_NAME);
updatePackage.Url.Should().BeEquivalentTo(LATEST_TEST_URL);
}
}
}

View File

@ -1,61 +0,0 @@
using System;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
class GetAvilableUpdateFixture : CoreTest
{
private static Version _latestsTestVersion = new Version("0.6.0.3");
private static string _latestsTestUrl = "http://update.nzbdrone.com/_test/NzbDrone.master.0.6.0.3.zip";
private static string _latestsTestFileName = "NzbDrone.master.0.6.0.3.zip";
[SetUp]
public void Setup()
{
WithStrictMocker();
Mocker.GetMock<IConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.Resolve<HttpProvider>();
}
[TestCase("0.6.0.9")]
[TestCase("0.7.0.1")]
[TestCase("1.0.0.0")]
public void should_return_null_if_latests_is_lower_than_current_version(string currentVersion)
{
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(new Version(currentVersion));
updatePackage.Should().BeNull();
}
[Test]
public void should_return_null_if_latests_is_equal_to_current_version()
{
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(_latestsTestVersion);
updatePackage.Should().BeNull();
}
[TestCase("0.0.0.0")]
[TestCase("0.0.0.1")]
[TestCase("0.0.10.10")]
public void should_return_update_if_latests_is_higher_than_current_version(string currentVersion)
{
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(new Version(currentVersion));
updatePackage.Should().NotBeNull();
updatePackage.Version.Should().Be(_latestsTestVersion);
updatePackage.FileName.Should().BeEquivalentTo(_latestsTestFileName);
updatePackage.Url.Should().BeEquivalentTo(_latestsTestUrl);
}
}
}

View File

@ -1,14 +1,9 @@
using System.Linq;
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Qualities
@ -20,7 +15,7 @@ namespace NzbDrone.Core.Test.Qualities
[Test]
public void Init_should_add_two_profiles()
{
Subject.Init();
Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(2));
@ -35,7 +30,7 @@ namespace NzbDrone.Core.Test.Qualities
.Setup(s => s.All())
.Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList());
Subject.Init();
Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never());

View File

@ -1,11 +1,7 @@
using System.Linq;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
@ -18,26 +14,10 @@ namespace NzbDrone.Core.Test.Qualities
[Test]
public void Init_should_add_all_sizes()
{
Subject.Init();
Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1));
//Todo: Should we validate each was inserted exactly as configured?
//var types = Mocker.Resolve<QualitySizeService>().All();
//types.Should().HaveCount(10);
//types.Should().Contain(e => e.Name == "SDTV" && e.QualityId == 1);
//types.Should().Contain(e => e.Name == "DVD" && e.QualityId == 2);
//types.Should().Contain(e => e.Name == "WEBDL-480p" && e.QualityId == 8);
//types.Should().Contain(e => e.Name == "HDTV-720p" && e.QualityId == 4);
//types.Should().Contain(e => e.Name == "HDTV-1080p" && e.QualityId == 9);
//types.Should().Contain(e => e.Name == "Raw-HD" && e.QualityId == 10);
//types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityId == 5);
//types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityId == 3);
//types.Should().Contain(e => e.Name == "Bluray720p" && e.QualityId == 6);
//types.Should().Contain(e => e.Name == "Bluray1080p" && e.QualityId == 7);
}
[Test]
@ -50,7 +30,7 @@ namespace NzbDrone.Core.Test.Qualities
new QualitySize { QualityId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 }
});
Subject.Init();
Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IQualitySizeRepository>()
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 2));

View File

@ -211,7 +211,7 @@ namespace NzbDrone.Core.Configuration
public string UpdateUrl
{
get { return GetValue("UpdateUrl", UpdateProvider.DEFAULT_UPDATE_URL); }
get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/_release/"); }
set { SetValue("UpdateUrl", value); }
}

View File

@ -32,7 +32,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
//Todo: Make this use NzbRestrictions - How should whitelist be used? Will it override blacklist or vice-versa?
//var allowed = _configService.AllowedReleaseGroups;
var allowed = "";
const string allowed = "";
if (string.IsNullOrWhiteSpace(allowed))
return true;

View File

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Lifecycle
{
notification.CurrentMessage = "Checking for updates";
var updatePackage = _updateProvider.GetAvilableUpdate(_environmentProvider.Version);
var updatePackage = _updateProvider.GetAvailableUpdate(_environmentProvider.Version);
//No updates available
if (updatePackage == null)

View File

@ -195,7 +195,7 @@ namespace NzbDrone.Core.Providers
}
catch (Exception ex)
{
Logger.WarnException("Failed to move epiosde file from drop folder: " + file, ex);
Logger.WarnException("Failed to move episode file from drop folder: " + file, ex);
throw;
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@ -20,19 +19,19 @@ namespace NzbDrone.Core.Providers
private readonly EnvironmentProvider _environmentProvider;
private readonly DiskProvider _diskProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly Logger _logger;
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
public const string DEFAULT_UPDATE_URL = @"http://update.nzbdrone.com/_release/";
public UpdateProvider(IHttpProvider httpProvider, IConfigService configService,
EnvironmentProvider environmentProvider, DiskProvider diskProvider)
EnvironmentProvider environmentProvider, DiskProvider diskProvider, Logger logger)
{
_httpProvider = httpProvider;
_configService = configService;
_environmentProvider = environmentProvider;
_diskProvider = diskProvider;
_logger = logger;
}
public UpdateProvider()
@ -40,7 +39,7 @@ namespace NzbDrone.Core.Providers
}
private List<UpdatePackage> GetAvailablePackages()
private IEnumerable<UpdatePackage> GetAvailablePackages()
{
var updateList = new List<UpdatePackage>();
var updateUrl = _configService.UpdateUrl;
@ -59,17 +58,17 @@ namespace NzbDrone.Core.Providers
return updateList;
}
public virtual UpdatePackage GetAvilableUpdate(Version currentVersion)
public virtual UpdatePackage GetAvailableUpdate(Version currentVersion)
{
var latestAvailable = GetAvailablePackages().OrderByDescending(c => c.Version).FirstOrDefault();
if (latestAvailable != null && latestAvailable.Version > currentVersion)
{
logger.Debug("An update is available ({0}) => ({1})", currentVersion, latestAvailable.Version);
_logger.Debug("An update is available ({0}) => ({1})", currentVersion, latestAvailable.Version);
return latestAvailable;
}
logger.Trace("No updates available");
_logger.Trace("No updates available");
return null;
}

View File

@ -52,11 +52,6 @@ namespace NzbDrone.Core.Qualities
return _qualityProfileRepository.Get(id);
}
public void Init()
{
}
public void Handle(ApplicationStartedEvent message)
{
if (All().Any()) return;