Application will automatically restart on db error.

Added SyncProvider Tests
pull/4/head
kay.one 14 years ago
parent fcf51978f9
commit 8cade435d1

@ -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" />

@ -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("");
}
}
}

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

@ -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);

@ -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.Warn("Restarting application");
HttpRuntime.UnloadAppDomain();
}
}
protected void Application_BeginRequest()

Loading…
Cancel
Save