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

Application will automatically restart on db error.

Added SyncProvider Tests
This commit is contained in:
kay.one 2011-04-09 19:28:54 -07:00
parent fcf51978f9
commit 8cade435d1
5 changed files with 65 additions and 5 deletions

View File

@ -93,6 +93,7 @@
<Compile Include="AutoMoq\Unity\AutoMockingContainerExtension.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SyncProviderTest.cs" />
<Compile Include="RootDirProviderTest.cs" />
<Compile Include="RssProviderTest.cs" />
<Compile Include="HistoryProviderTest.cs" />

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SyncProviderTest
{
[Test]
public void None_existing_folder_returns_empty_list()
{
string path = "d:\\bad folder";
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>(MockBehavior.Strict)
.Setup(m => m.FolderExists(path)).Returns(false);
var result = mocker.Resolve<SyncProvider>().GetUnmappedFolders(path);
Assert.IsNotNull(result);
Assert.IsEmpty(result);
mocker.VerifyAllMocks();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void empty_folder_path_throws()
{
var mocker = new AutoMoqer();
mocker.Resolve<SyncProvider>().GetUnmappedFolders("");
}
}
}

View File

@ -30,6 +30,11 @@ namespace NzbDrone.Core.Providers
_episodeProvider = episodeProvider;
}
public MediaFileProvider()
{
}
/// <summary>
/// Scans the specified series folder for media files
/// </summary>

View File

@ -41,15 +41,17 @@ namespace NzbDrone.Core.Providers
{
Logger.Debug("Generating list of unmapped folders");
if (String.IsNullOrEmpty(path))
throw new InvalidOperationException("Invalid path provided");
throw new ArgumentException("Invalid path provided", "path");
var results = new List<String>();
if (!_diskProvider.FolderExists(path))
{
Logger.Debug("Path supplied does not exist: {0}", path);
return null;
return results;
}
var results = new List<String>();
foreach (string seriesFolder in _diskProvider.GetDirectories(path))
{
var cleanPath = Parser.NormalizePath(new DirectoryInfo(seriesFolder).FullName);

View File

@ -1,4 +1,5 @@
using System;
using System.Data.SQLite;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
@ -74,11 +75,17 @@ namespace NzbDrone.Web
{
Response.Redirect(Request.ApplicationPath);
}
return;
}
else
Logger.FatalException(lastError.Message, lastError);
if (lastError is SQLiteException)
{
Logger.FatalException(lastError.Message, lastError);
Logger.Warn("Restarting application");
HttpRuntime.UnloadAppDomain();
}
}
protected void Application_BeginRequest()