Fixed most of the broken tests
This commit is contained in:
parent
34038245eb
commit
7ed148b12c
|
@ -23,7 +23,7 @@ namespace NzbDrone.Api.RootFolders
|
|||
|
||||
private Response AddRootFolder()
|
||||
{
|
||||
var dir = _rootFolderService.Add(Request.Body.FromJson<RootDir>());
|
||||
var dir = _rootFolderService.Add(Request.Body.FromJson<RootFolder>());
|
||||
return dir.AsResponse(HttpStatusCode.Created);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@
|
|||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NBuilder" version="3.0.1.1" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -69,9 +69,9 @@
|
|||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -1,101 +1,101 @@
|
|||
using System.Linq;
|
||||
using Eloquera.Client;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
[TestFixture]
|
||||
public class ObjectDatabaseFixture : ObjectDbTest
|
||||
{
|
||||
private Series testSeries;
|
||||
private Episode testEpisode;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithObjectDb();
|
||||
|
||||
testSeries = Builder<Series>.CreateNew().Build();
|
||||
testEpisode = Builder<Episode>.CreateNew().Build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_write_to_database()
|
||||
{
|
||||
Db.Insert(testSeries);
|
||||
|
||||
Db.AsQueryable<Series>().Should().HaveCount(1);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_store_dirty_data_in_cache()
|
||||
{
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
||||
|
||||
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_store_nested_objects()
|
||||
{
|
||||
testEpisode.Series = testSeries;
|
||||
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_nested_objects()
|
||||
{
|
||||
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
testEpisode.Series.Title = "UpdatedTitle";
|
||||
|
||||
Db.Update(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
||||
Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void new_objects_should_get_id()
|
||||
{
|
||||
Db.Insert(testSeries);
|
||||
testSeries.Id.Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_read_unknow_type()
|
||||
{
|
||||
Db.AsQueryable<UnKnowType>().ToList().Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnKnowType
|
||||
{
|
||||
[ID]
|
||||
public string Id;
|
||||
public string Field1 { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
using System.Linq;
|
||||
using Eloquera.Client;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore
|
||||
{
|
||||
[TestFixture]
|
||||
public class ObjectDatabaseFixture : ObjectDbTest
|
||||
{
|
||||
private Series testSeries;
|
||||
private Episode testEpisode;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithObjectDb();
|
||||
|
||||
testSeries = Builder<Series>.CreateNew().Build();
|
||||
testEpisode = Builder<Episode>.CreateNew().Build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_write_to_database()
|
||||
{
|
||||
Db.Insert(testSeries);
|
||||
|
||||
Db.AsQueryable<Series>().Should().HaveCount(1);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_store_dirty_data_in_cache()
|
||||
{
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
||||
|
||||
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().BeNull();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_store_nested_objects()
|
||||
{
|
||||
testEpisode.Series = testSeries;
|
||||
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_update_nested_objects()
|
||||
{
|
||||
testEpisode.Series = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Db.Insert(testEpisode);
|
||||
|
||||
testEpisode.Series.Title = "UpdatedTitle";
|
||||
|
||||
Db.Update(testEpisode);
|
||||
|
||||
Db.AsQueryable<Episode>().Should().HaveCount(1);
|
||||
Db.AsQueryable<Episode>().Single().Series.Should().NotBeNull();
|
||||
Db.AsQueryable<Episode>().Single().Series.Title.Should().Be("UpdatedTitle");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void new_objects_should_get_id()
|
||||
{
|
||||
Db.Insert(testSeries);
|
||||
testSeries.Id.Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_read_unknow_type()
|
||||
{
|
||||
Db.AsQueryable<UnknownType>().ToList().Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnknownType
|
||||
{
|
||||
[ID]
|
||||
public string Id;
|
||||
public string Field1 { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public abstract class CoreTest : TestBase
|
||||
{
|
||||
protected static ProgressNotification MockNotification
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ProgressNotification("Mock notification");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void ThrowException()
|
||||
{
|
||||
throw new ApplicationException("This is a message for test exception");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class CoreTest<TSubject> : CoreTest
|
||||
{
|
||||
[SetUp]
|
||||
public void CoreTestSetup()
|
||||
{
|
||||
Subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
protected TSubject Subject { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
|
||||
{
|
||||
|
||||
private TSubject _subject;
|
||||
|
||||
|
||||
protected TSubject Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_subject == null)
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
return _subject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void InitiateSubject()
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,52 +9,6 @@ using PetaPoco;
|
|||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
|
||||
public abstract class CoreTest : TestBase
|
||||
{
|
||||
protected static ProgressNotification MockNotification
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ProgressNotification("Mock notification");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void ThrowException()
|
||||
{
|
||||
throw new ApplicationException("This is a message for test exception");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract class CoreTest<TSubject> : CoreTest
|
||||
{
|
||||
private TSubject _subject;
|
||||
|
||||
|
||||
protected TSubject Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_subject == null)
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
return _subject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void InitiateSubject()
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class SqlCeTest : CoreTest
|
||||
{
|
||||
private string _dbTemplateName;
|
||||
|
@ -145,4 +99,31 @@ namespace NzbDrone.Core.Test.Framework
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
|
||||
{
|
||||
|
||||
private TSubject _subject;
|
||||
|
||||
|
||||
protected TSubject Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_subject == null)
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
return _subject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void InitiateSubject()
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,9 @@
|
|||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prowlin, Version=0.9.4456.26422, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
@ -147,7 +147,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
||||
<Compile Include="Framework\CoreTestTSubject.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="Framework\ObjectDbTest.cs" />
|
||||
<Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" />
|
||||
<Compile Include="IndexerTests\NzbxFixture.cs" />
|
||||
|
@ -156,7 +156,7 @@
|
|||
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\DownloadNzbFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\ContainsRecentEpisode.cs" />
|
||||
<Compile Include="ProviderTests\RootDirProviderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="ProviderTests\RootFolderServiceTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="ProviderTests\SearchTests\ProcessResultsFixture.cs" />
|
||||
<Compile Include="ProviderTests\SearchTests\DailyEpisodeSearchTests\CheckReportFixture.cs" />
|
||||
<Compile Include="ProviderTests\SearchTests\EpisodeSearchTests\CheckReportFixture.cs" />
|
||||
|
@ -257,7 +257,7 @@
|
|||
<Compile Include="ProviderTests\DecisionEngineTests\AllowedDownloadSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\JobProviderTests\JobProviderFixture.cs" />
|
||||
<Compile Include="QualityTest.cs" />
|
||||
<Compile Include="ProviderTests\RootDirProviderTests\RootDirProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\RootFolderServiceTests\RootFolderServiceFixture.cs" />
|
||||
<Compile Include="ProviderTests\IndexerProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\HistoryProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
|
||||
|
|
|
@ -22,14 +22,14 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class FreeSpaceOnDrivesFixture : SqlCeTest
|
||||
public class FreeSpaceOnDrivesFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void should_return_one_drive_when_only_one_root_dir_exists()
|
||||
{
|
||||
Mocker.GetMock<IDatabase>()
|
||||
.Setup(s => s.Fetch<RootDir>())
|
||||
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" } });
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
||||
|
@ -47,10 +47,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
[Test]
|
||||
public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist()
|
||||
{
|
||||
Mocker.GetMock<IDatabase>()
|
||||
.Setup(s => s.Fetch<RootDir>())
|
||||
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" },
|
||||
new RootDir { Id = 2, Path = @"C:\Test\TV2" }});
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" },
|
||||
new RootFolder { Id = 2, Path = @"C:\Test\TV2" }});
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(It.IsAny<String>()))
|
||||
|
@ -68,10 +68,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
[Test]
|
||||
public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist()
|
||||
{
|
||||
Mocker.GetMock<IDatabase>()
|
||||
.Setup(s => s.Fetch<RootDir>())
|
||||
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" },
|
||||
new RootDir { Id = 2, Path = @"D:\Test\TV" }});
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" },
|
||||
new RootFolder { Id = 2, Path = @"D:\Test\TV" }});
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
||||
|
@ -93,9 +93,9 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
[Test]
|
||||
public void should_skip_rootDir_if_not_found_on_disk()
|
||||
{
|
||||
Mocker.GetMock<IDatabase>()
|
||||
.Setup(s => s.Fetch<RootDir>())
|
||||
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" } });
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
|
@ -4,7 +4,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -16,18 +15,22 @@ using NzbDrone.Core.RootFolders;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RootFolderServiceTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class RootDirProviderFixture : CoreTest<RootFolderService>
|
||||
public class RootFolderServiceFixture : CoreTest<RootFolderService>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(m => m.FolderExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
.Setup(m => m.FolderExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder>());
|
||||
}
|
||||
|
||||
private void WithNoneExistingFolder()
|
||||
|
@ -37,12 +40,12 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
.Returns(false);
|
||||
}
|
||||
|
||||
|
||||
[TestCase("D:\\TV Shows\\")]
|
||||
[TestCase("//server//folder")]
|
||||
public void should_be_able_to_add_root_dir(string path)
|
||||
{
|
||||
var root = new RootDir { Path = path };
|
||||
var root = new RootFolder { Path = path };
|
||||
|
||||
Subject.Add(root);
|
||||
|
||||
Mocker.GetMock<IRootFolderRepository>().Verify(c => c.Add(root), Times.Once());
|
||||
|
@ -53,7 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
{
|
||||
WithNoneExistingFolder();
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootDir { Path = "C:\\TEST" }));
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -67,7 +70,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
{
|
||||
WithNoneExistingFolder();
|
||||
|
||||
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootDir>());
|
||||
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder>());
|
||||
|
||||
const string path = "d:\\bad folder";
|
||||
|
||||
|
@ -90,17 +93,16 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|||
public void invalid_folder_path_throws_on_add(string path)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Mocker.Resolve<RootFolderService>().Add(new RootDir { Id = 0, Path = path })
|
||||
Mocker.Resolve<RootFolderService>().Add(new RootFolder { Id = 0, Path = path })
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void adding_duplicated_root_folder_should_throw()
|
||||
{
|
||||
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootDir> { new RootDir { Path = "C:\\TV" } });
|
||||
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder> { new RootFolder { Path = "C:\\TV" } });
|
||||
|
||||
Subject.Add(new RootDir { Path = @"C:\TV" });
|
||||
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootDir { Path = @"C:\TV" }));
|
||||
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\TV" }));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
<package id="NCrunch.Framework" version="1.43.0.23" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
<package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" />
|
||||
<package id="SignalR.Server" version="0.5.3" targetFramework="net40" />
|
||||
<package id="Unity" version="2.1.505.2" targetFramework="net40" />
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Eloquera.Client;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public abstract class BaseRepositoryModel
|
||||
{
|
||||
[ID]
|
||||
public int Id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public interface IBasicRepository<TModel>
|
||||
{
|
||||
List<TModel> All();
|
||||
TModel Get(int rootFolderId);
|
||||
TModel Add(TModel rootFolder);
|
||||
void Delete(int rootFolderId);
|
||||
}
|
||||
|
||||
public abstract class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseRepositoryModel, new()
|
||||
{
|
||||
public BasicRepository(EloqueraDb eloqueraDb)
|
||||
{
|
||||
EloqueraDb = eloqueraDb;
|
||||
}
|
||||
|
||||
protected EloqueraDb EloqueraDb { get; private set; }
|
||||
|
||||
|
||||
public List<TModel> All()
|
||||
{
|
||||
return EloqueraDb.AsQueryable<TModel>().ToList();
|
||||
}
|
||||
|
||||
public TModel Get(int rootFolderId)
|
||||
{
|
||||
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == rootFolderId);
|
||||
}
|
||||
|
||||
public TModel Add(TModel rootFolder)
|
||||
{
|
||||
return EloqueraDb.Insert(rootFolder);
|
||||
}
|
||||
|
||||
public void Delete(int rootFolderId)
|
||||
{
|
||||
var itemToDelete = Get(rootFolderId);
|
||||
EloqueraDb.Delete(itemToDelete);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,10 +18,10 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
|
||||
using (var dataReader = Database.ExecuteQuery("SELECT * from RootDirs"))
|
||||
{
|
||||
var dirs = new List<RootDir>();
|
||||
var dirs = new List<RootFolder>();
|
||||
while (dataReader.Read())
|
||||
{
|
||||
var rootFolder = new RootDir { Path = dataReader["Path"].ToString() };
|
||||
var rootFolder = new RootFolder { Path = dataReader["Path"].ToString() };
|
||||
dirs.Add(rootFolder);
|
||||
}
|
||||
objectDb.InsertMany(dirs);
|
||||
|
|
|
@ -231,6 +231,8 @@
|
|||
</Compile>
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="ContainerExtentions.cs" />
|
||||
<Compile Include="Datastore\BaseRepositoryModel.cs" />
|
||||
<Compile Include="Datastore\BasicRepository.cs" />
|
||||
<Compile Include="Datastore\ConnectionFactory.cs" />
|
||||
<Compile Include="Datastore\EloqueraDb.cs" />
|
||||
<Compile Include="Datastore\EloqueraDbFactory.cs" />
|
||||
|
@ -595,7 +597,7 @@
|
|||
<Compile Include="Repository\Config.cs" />
|
||||
<Compile Include="Repository\Quality\QualityType.cs" />
|
||||
<Compile Include="Repository\Quality\QualityProfile.cs" />
|
||||
<Compile Include="Repository\RootDir.cs" />
|
||||
<Compile Include="RootFolders\RootFolder.cs" />
|
||||
<Compile Include="Repository\SceneMapping.cs" />
|
||||
<Compile Include="Repository\Series.cs" />
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
namespace NzbDrone.Core.RootFolders
|
||||
{
|
||||
|
||||
[TableName("RootDirs")]
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
public class RootDir : BaseModel
|
||||
public class RootFolder : BaseRepositoryModel
|
||||
{
|
||||
public string Path { get; set; }
|
||||
|
|
@ -6,64 +6,14 @@ using System.Linq;
|
|||
|
||||
namespace NzbDrone.Core.RootFolders
|
||||
{
|
||||
|
||||
public abstract class BaseModel
|
||||
{
|
||||
[ID]
|
||||
public int Id;
|
||||
}
|
||||
|
||||
public interface IBasicRepository<TModel>
|
||||
{
|
||||
List<TModel> All();
|
||||
TModel Get(int rootFolderId);
|
||||
TModel Add(TModel rootFolder);
|
||||
void Delete(int rootFolderId);
|
||||
}
|
||||
|
||||
|
||||
public abstract class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseModel, new()
|
||||
{
|
||||
|
||||
|
||||
public BasicRepository(EloqueraDb eloqueraDb)
|
||||
{
|
||||
EloqueraDb = eloqueraDb;
|
||||
}
|
||||
|
||||
protected EloqueraDb EloqueraDb { get; private set; }
|
||||
|
||||
|
||||
public List<TModel> All()
|
||||
{
|
||||
return EloqueraDb.AsQueryable<TModel>().ToList();
|
||||
}
|
||||
|
||||
public TModel Get(int rootFolderId)
|
||||
{
|
||||
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == rootFolderId);
|
||||
}
|
||||
|
||||
public TModel Add(TModel rootFolder)
|
||||
{
|
||||
return EloqueraDb.Insert(rootFolder);
|
||||
}
|
||||
|
||||
public void Delete(int rootFolderId)
|
||||
{
|
||||
var itemToDelete = Get(rootFolderId);
|
||||
EloqueraDb.Delete(itemToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRootFolderRepository : IBasicRepository<RootDir>
|
||||
public interface IRootFolderRepository : IBasicRepository<RootFolder>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically.
|
||||
public class RootFolderRepository : BasicRepository<RootDir>, IRootFolderRepository
|
||||
public class RootFolderRepository : BasicRepository<RootFolder>, IRootFolderRepository
|
||||
{
|
||||
public RootFolderRepository(EloqueraDb eloqueraDb)
|
||||
: base(eloqueraDb)
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace NzbDrone.Core.RootFolders
|
|||
{
|
||||
public interface IRootFolderService
|
||||
{
|
||||
List<RootDir> All();
|
||||
RootDir Add(RootDir rootDir);
|
||||
List<RootFolder> All();
|
||||
RootFolder Add(RootFolder rootDir);
|
||||
void Remove(int rootDirId);
|
||||
List<String> GetUnmappedFolders(string path);
|
||||
Dictionary<string, ulong> FreeSpaceOnDrives();
|
||||
|
@ -32,12 +32,12 @@ namespace NzbDrone.Core.RootFolders
|
|||
_seriesProvider = seriesProvider;
|
||||
}
|
||||
|
||||
public virtual List<RootDir> All()
|
||||
public virtual List<RootFolder> All()
|
||||
{
|
||||
return _rootFolderRepository.All();
|
||||
}
|
||||
|
||||
public virtual RootDir Add(RootDir rootDir)
|
||||
public virtual RootFolder Add(RootFolder rootDir)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path))
|
||||
throw new ArgumentException("Invalid path");
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<RootNamespace>NzbDrone.Services.Api</RootNamespace>
|
||||
<AssemblyName>NzbDrone.Services.Api</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
|
@ -152,7 +152,7 @@
|
|||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>1306</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost/NzbDrone.Services.Api</IISUrl>
|
||||
<IISUrl>http://localhost:1306/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
|
|
|
@ -74,9 +74,9 @@
|
|||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NBuilder" version="3.0.1.1" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -70,9 +70,9 @@
|
|||
<Reference Include="NLog">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace NzbDrone.Test.Common
|
|||
{
|
||||
protected const string INTEGRATION_TEST = "Integration Test";
|
||||
|
||||
|
||||
private AutoMoqer _mocker;
|
||||
protected AutoMoqer Mocker
|
||||
{
|
||||
|
@ -29,7 +28,6 @@ namespace NzbDrone.Test.Common
|
|||
|
||||
protected Mock<RestProvider> MockedRestProvider { get; private set; }
|
||||
|
||||
|
||||
private string VirtualPath
|
||||
{
|
||||
get
|
||||
|
@ -41,7 +39,6 @@ namespace NzbDrone.Test.Common
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected string TempFolder { get; private set; }
|
||||
|
||||
[SetUp]
|
||||
|
@ -83,7 +80,6 @@ namespace NzbDrone.Test.Common
|
|||
_mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
|
||||
protected void WithTempAsAppPath()
|
||||
{
|
||||
Mocker.GetMock<EnvironmentProvider>()
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<package id="CommonServiceLocator" version="1.0" />
|
||||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NLog" version="2.0.0.2000" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
<package id="Unity" version="2.1.505.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -53,9 +53,9 @@
|
|||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" />
|
||||
<package id="NBuilder" version="3.0.1.1" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -64,7 +64,7 @@
|
|||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<package id="DotNetZip" version="1.9.1.8" />
|
||||
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
|
||||
<package id="NUnit" version="2.6.0.12054" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
<package id="Selenium.WebDriver" version="2.25.1" targetFramework="net40" />
|
||||
</packages>
|
|
@ -2,7 +2,6 @@
|
|||
<FileVersion>1</FileVersion>
|
||||
<AutoEnableOnStartup>True</AutoEnableOnStartup>
|
||||
<AllowParallelTestExecution>true</AllowParallelTestExecution>
|
||||
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
|
||||
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
|
||||
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
|
||||
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>
|
||||
|
|
Loading…
Reference in New Issue