fixed some broken tests.
This commit is contained in:
parent
fd8ad73476
commit
edf7cc678d
|
@ -80,9 +80,9 @@
|
|||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerPort>12766</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:55352/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
|
|
|
@ -31,10 +31,10 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "Port";
|
||||
const string value = "8989";
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().GetValue(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "Port";
|
||||
const int value = 8989;
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().GetValueInt(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
|
@ -57,20 +57,20 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "LaunchBrowser";
|
||||
const bool value = true;
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().GetValueBoolean(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetLaunchBrowser_Success()
|
||||
{
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().LaunchBrowser;
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(true);
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,10 @@ namespace NzbDrone.Common.Test
|
|||
{
|
||||
const int value = 8989;
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().Port;
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,10 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "LaunchBrowser";
|
||||
const bool value = false;
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<ConfigFileProvider>().SetValue(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().LaunchBrowser;
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
@ -106,10 +106,10 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "Port";
|
||||
const int value = 12345;
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<ConfigFileProvider>().SetValue(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().Port;
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
@ -120,10 +120,10 @@ namespace NzbDrone.Common.Test
|
|||
const string key = "Hello";
|
||||
const string value = "World";
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().GetValue(key, value);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(value);
|
||||
}
|
||||
|
||||
|
@ -131,10 +131,10 @@ namespace NzbDrone.Common.Test
|
|||
public void GetAuthenticationType_No_Existing_Value()
|
||||
{
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().AuthenticationType;
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(AuthenticationType.Anonymous);
|
||||
}
|
||||
|
||||
|
@ -144,22 +144,22 @@ namespace NzbDrone.Common.Test
|
|||
|
||||
Mocker.Resolve<ConfigFileProvider>().SetValue("AuthenticationType", 1);
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<ConfigFileProvider>().AuthenticationType;
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().Be(AuthenticationType.Windows);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Guid_should_return_the_same_every_time()
|
||||
{
|
||||
//Act
|
||||
|
||||
var firstResponse = Mocker.Resolve<ConfigFileProvider>().Guid;
|
||||
var secondResponse = Mocker.Resolve<ConfigFileProvider>().Guid;
|
||||
|
||||
|
||||
//Assert
|
||||
|
||||
secondResponse.Should().Be(firstResponse);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@ namespace NzbDrone.Core.Test.Framework
|
|||
catch { }
|
||||
}
|
||||
|
||||
//Delete App_data folder
|
||||
/* //Delete App_data folder
|
||||
var appData = new EnvironmentProvider().GetAppDataPath();
|
||||
|
||||
if (Directory.Exists(appData))
|
||||
{
|
||||
Directory.Delete(appData, true);
|
||||
}
|
||||
//Directory.Delete(appData, true);
|
||||
}*/
|
||||
|
||||
TestDbHelper.CreateDataBaseTemplate();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public abstract class CoreTest<TSubject> : CoreTest 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>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -138,6 +138,7 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Framework\CoreTestTSubject.cs" />
|
||||
<Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" />
|
||||
<Compile Include="IndexerTests\NzbxFixture.cs" />
|
||||
<Compile Include="JobTests\RenameSeasonJobFixture.cs" />
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
settings.Enable = true;
|
||||
indexerProvider.SaveSettings(settings);
|
||||
|
||||
//Assert
|
||||
|
||||
indexerProvider.All();
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
settings.Enable = false;
|
||||
indexerProvider.SaveSettings(settings);
|
||||
|
||||
//Assert
|
||||
|
||||
|
||||
indexerProvider.All().Should().HaveCount(1);
|
||||
indexerProvider.GetEnabledIndexers().Should().BeEmpty();
|
||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
var indexerProvider = Mocker.Resolve<IndexerProvider>();
|
||||
|
||||
|
||||
//Assert
|
||||
|
||||
indexerProvider.All();
|
||||
indexerProvider.All().Should().HaveCount(1);
|
||||
indexerProvider.GetEnabledIndexers().Should().HaveCount(1);
|
||||
|
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
var indexerProvider = Mocker.Resolve<IndexerProvider>();
|
||||
|
||||
|
||||
//Assert
|
||||
|
||||
indexerProvider.All();
|
||||
indexerProvider.All().Should().HaveCount(1);
|
||||
indexerProvider.GetEnabledIndexers().Should().HaveCount(0);
|
||||
|
|
|
@ -71,12 +71,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { fakeJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
//Act
|
||||
|
||||
ResetLastExecution();
|
||||
Mocker.Resolve<JobProvider>().QueueScheduled();
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
var settings = Mocker.Resolve<JobProvider>().All();
|
||||
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
|
||||
fakeJob.ExecutionCount.Should().Be(1);
|
||||
|
@ -88,12 +88,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { brokenJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
//Act
|
||||
|
||||
ResetLastExecution();
|
||||
Mocker.Resolve<JobProvider>().QueueScheduled();
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
var settings = Mocker.Resolve<JobProvider>().All();
|
||||
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
|
||||
settings.First().Success.Should().BeFalse();
|
||||
|
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { fakeJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
//Act
|
||||
|
||||
ResetLastExecution();
|
||||
|
||||
Mocker.Resolve<JobProvider>().QueueScheduled();
|
||||
|
@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
Mocker.Resolve<JobProvider>().QueueScheduled();
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
fakeJob.ExecutionCount.Should().Be(1);
|
||||
}
|
||||
|
||||
|
@ -131,13 +131,13 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
|
||||
//Act
|
||||
|
||||
jobProvider.QueueJob(typeof(FakeJob));
|
||||
WaitForQueue();
|
||||
jobProvider.QueueJob(typeof(FakeJob));
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
jobProvider.Queue.Should().BeEmpty();
|
||||
fakeJob.ExecutionCount.Should().Be(2);
|
||||
}
|
||||
|
@ -170,14 +170,14 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
//Act
|
||||
|
||||
jobProvider.QueueJob(typeof(BrokenJob));
|
||||
WaitForQueue();
|
||||
|
||||
jobProvider.QueueJob(typeof(BrokenJob));
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
brokenJob.ExecutionCount.Should().Be(2);
|
||||
ExceptionVerification.ExpectedErrors(2);
|
||||
}
|
||||
|
@ -192,12 +192,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
|
||||
//Act
|
||||
|
||||
jobProvider.QueueJob(typeof(SlowJob));
|
||||
jobProvider.QueueScheduled();
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
slowJob.ExecutionCount.Should().Be(1);
|
||||
fakeJob.ExecutionCount.Should().Be(0);
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
|
||||
//assert
|
||||
|
||||
var timers = jobProvider.All();
|
||||
timers.Should().HaveCount(1);
|
||||
timers[0].Interval.Should().Be((Int32)fakeJob.DefaultInterval.TotalMinutes);
|
||||
|
@ -261,7 +261,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
Mocker.Resolve<JobProvider>();
|
||||
}
|
||||
|
||||
var Mocker2 = new AutoMoqer();
|
||||
|
@ -270,7 +270,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
var assertjobProvider = Mocker2.Resolve<JobProvider>();
|
||||
var timers = assertjobProvider.All();
|
||||
|
||||
//Assert
|
||||
|
||||
timers.Should().HaveCount(1);
|
||||
timers[0].Enable.Should().BeTrue();
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
Mocker.Resolve<JobProvider>();
|
||||
|
||||
|
||||
//Assert
|
||||
|
||||
var registeredJobs = Db.Fetch<JobDefinition>();
|
||||
registeredJobs.Should().HaveCount(1);
|
||||
registeredJobs.First().TypeName.Should().Be(fakeJob.GetType().ToString());
|
||||
|
@ -350,7 +350,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
//Assert
|
||||
|
||||
jobProvider.All().Should().HaveCount(1);
|
||||
jobProvider.All().First().Enable.Should().BeFalse();
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
disabledJob.ExecutionCount.Should().Be(0);
|
||||
}
|
||||
|
||||
|
@ -376,14 +376,14 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { fakeJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
//Act
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
ResetLastExecution();
|
||||
jobProvider.QueueJob(typeof(FakeJob), 10);
|
||||
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
jobProvider.All().First().LastExecution.Should().HaveYear(2000);
|
||||
}
|
||||
|
||||
|
@ -393,13 +393,13 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { fakeJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
//Act
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
jobProvider.QueueJob(typeof(FakeJob), 10);
|
||||
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
jobProvider.All().First().Success.Should().BeFalse();
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
Options = new { TargetId = 12 }
|
||||
};
|
||||
|
||||
//Act
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
jobProvider.Queue.Add(stuckQueueItem);
|
||||
|
||||
|
@ -424,7 +424,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
jobProvider.QueueJob(stuckQueueItem.JobType, stuckQueueItem.Options);
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
fakeJob.ExecutionCount.Should().Be(1);
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
|
|||
|
||||
WaitForQueue();
|
||||
|
||||
//Assert
|
||||
|
||||
slowJob.ExecutionCount.Should().Be(1);
|
||||
disabledJob.ExecutionCount.Should().Be(1);
|
||||
}
|
||||
|
|
|
@ -14,93 +14,64 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class NewznabProviderTest : CoreTest
|
||||
public class NewznabProviderTest : CoreTest<NewznabProvider>
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithRealDb();
|
||||
InitiateSubject();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Save_should_clean_url_before_inserting()
|
||||
{
|
||||
//Setup
|
||||
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world" };
|
||||
var expectedUrl = "http://www.nzbdrone.com";
|
||||
const string expectedUrl = "http://www.nzbdrone.com";
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||
var result = Subject.Save(newznab);
|
||||
|
||||
//Assert
|
||||
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||
Db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Save_should_clean_url_before_updating()
|
||||
{
|
||||
//Setup
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com" };
|
||||
var expectedUrl = "http://www.nzbdrone.com";
|
||||
var newUrl = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world";
|
||||
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world" };
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
var result = Subject.Save(newznab);
|
||||
|
||||
newznab.Id = Convert.ToInt32(db.Insert(newznab));
|
||||
newznab.Url = newUrl;
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||
|
||||
//Assert
|
||||
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||
Subject.All().Single(c => c.Id == result).Url.Should().Be("http://www.nzbdrone.com");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Save_should_clean_url_before_inserting_when_url_is_not_empty()
|
||||
{
|
||||
//Setup
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "" };
|
||||
var expectedUrl = "";
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
var result = Subject.Save(newznab);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||
|
||||
//Assert
|
||||
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||
Subject.All().Single(c => c.Id == result).Url.Should().Be("");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Save_should_clean_url_before_updating_when_url_is_not_empty()
|
||||
{
|
||||
//Setup
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com" };
|
||||
var expectedUrl = "";
|
||||
var newUrl = "";
|
||||
|
||||
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "" };
|
||||
var result = Subject.Save(newznab);
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
newznab.Id = Convert.ToInt32(db.Insert(newznab));
|
||||
newznab.Url = newUrl;
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
|
||||
|
||||
//Assert
|
||||
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
|
||||
Db.Single<NewznabDefinition>(result).Url.Should().Be("");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("No longer clean newznab URLs")]
|
||||
public void SaveAll_should_clean_urls_before_updating()
|
||||
{
|
||||
//Setup
|
||||
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(d => d.Url = "http://www.nzbdrone.com")
|
||||
|
@ -108,25 +79,22 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
var expectedUrl = "http://www.nzbdrone.com";
|
||||
var newUrl = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world";
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.InsertMany(definitions);
|
||||
Db.InsertMany(definitions);
|
||||
|
||||
definitions.ToList().ForEach(d => d.Url = newUrl);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>().SaveAll(definitions);
|
||||
|
||||
//Assert
|
||||
db.Fetch<NewznabDefinition>().Where(d => d.Url == expectedUrl).Should().HaveCount(5);
|
||||
Subject.SaveAll(definitions);
|
||||
|
||||
|
||||
Db.Fetch<NewznabDefinition>().Where(d => d.Url == expectedUrl).Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Enabled_should_return_all_enabled_newznab_providers()
|
||||
{
|
||||
//Setup
|
||||
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.TheFirst(2)
|
||||
.With(d => d.Enable = false)
|
||||
|
@ -134,16 +102,13 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
.With(d => d.Enable = true)
|
||||
.Build();
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.InsertMany(definitions);
|
||||
Db.InsertMany(definitions);
|
||||
|
||||
|
||||
var result = Subject.Enabled();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().Enabled();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(3);
|
||||
result.All(d => d.Enable).Should().BeTrue();
|
||||
}
|
||||
|
@ -151,81 +116,54 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
[Test]
|
||||
public void All_should_return_all_newznab_providers()
|
||||
{
|
||||
//Setup
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.TheFirst(2)
|
||||
.With(d => d.Enable = false)
|
||||
.TheLast(3)
|
||||
.With(d => d.Enable = true)
|
||||
|
||||
var userIndexers = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.All().With(c => c.Url = "http://www.host.com/12")
|
||||
.Build();
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.InsertMany(definitions);
|
||||
Db.InsertMany(userIndexers);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<NewznabProvider>().All();
|
||||
var result = Subject.All();
|
||||
|
||||
result.Should().HaveCount(8);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void All_should_return_empty_list_when_no_indexers_exist()
|
||||
{
|
||||
Db.Delete<NewznabDefinition>("");
|
||||
|
||||
Subject.All().Should().NotBeNull();
|
||||
Subject.All().Should().BeEmpty();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_should_delete_newznab_provider()
|
||||
{
|
||||
//Setup
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.TheFirst(2)
|
||||
.With(d => d.Enable = false)
|
||||
.TheLast(3)
|
||||
.With(d => d.Enable = true)
|
||||
.Build();
|
||||
var toBeDelete = Subject.All()[2];
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
Subject.Delete(toBeDelete.Id);
|
||||
|
||||
db.InsertMany(definitions);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>().Delete(1);
|
||||
|
||||
//Assert
|
||||
var result = db.Fetch<NewznabDefinition>();
|
||||
result.Should().HaveCount(4);
|
||||
result.Any(d => d.Id == 1).Should().BeFalse();
|
||||
Subject.All().Should().NotBeEmpty();
|
||||
Subject.All().Should().NotContain(c => c.Id == toBeDelete.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitializeNewznabIndexers_should_initialize_new_indexers()
|
||||
public void InitializeNewznabIndexers_should_initialize_build_in_indexers()
|
||||
{
|
||||
//Setup
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(d => d.Url = "http://www.nzbdrone.com")
|
||||
.Build();
|
||||
var indexers = Subject.All();
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(definitions);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>();
|
||||
|
||||
//Assert
|
||||
var result = db.Fetch<NewznabDefinition>();
|
||||
result.Should().HaveCount(5);
|
||||
result.Should().OnlyContain(i => i.BuiltIn);
|
||||
indexers.Should().NotBeEmpty();
|
||||
indexers.Should().OnlyContain(i => i.BuiltIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitializeNewznabIndexers_should_initialize_new_indexers_only()
|
||||
{
|
||||
//Setup
|
||||
|
||||
var definitions = Builder<NewznabDefinition>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(d => d.Id = 0)
|
||||
|
@ -235,88 +173,46 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
.With(d => d.Url = "http://www.nzbdrone.com")
|
||||
.Build();
|
||||
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.Insert(definitions[0]);
|
||||
db.Insert(definitions[2]);
|
||||
Db.Insert(definitions[0]);
|
||||
Db.Insert(definitions[2]);
|
||||
|
||||
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(definitions);
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>();
|
||||
|
||||
//Assert
|
||||
var result = db.Fetch<NewznabDefinition>();
|
||||
result.Should().HaveCount(2);
|
||||
var result = Db.Fetch<NewznabDefinition>();
|
||||
result.Where(d => d.Url == "http://www.nzbdrone.com").Should().HaveCount(1);
|
||||
result.Where(d => d.Url == "http://www.nzbdrone2.com").Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitializeNewznabIndexers_should_update_matching_indexer_to_be_builtin()
|
||||
{
|
||||
//Setup
|
||||
var definition = Builder<NewznabDefinition>.CreateNew()
|
||||
.With(d => d.Url = "http://www.nzbdrone2.com")
|
||||
.With(d => d.BuiltIn = false)
|
||||
.Build();
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.Insert(definition);
|
||||
|
||||
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(new List<NewznabDefinition> { definition });
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>();
|
||||
|
||||
//Assert
|
||||
var result = db.Fetch<NewznabDefinition>();
|
||||
result.Should().HaveCount(1);
|
||||
result.First().BuiltIn.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitializeNewznabIndexers_should_not_blow_up_if_more_than_one_indexer_with_the_same_url_is_found()
|
||||
{
|
||||
//Setup
|
||||
var definition = Builder<NewznabDefinition>.CreateNew()
|
||||
.With(d => d.Url = "http://www.nzbdrone2.com")
|
||||
.With(d => d.BuiltIn = false)
|
||||
.Build();
|
||||
|
||||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
db.Insert(definition);
|
||||
db.Insert(definition);
|
||||
Db.Insert(definition);
|
||||
Db.Insert(definition);
|
||||
|
||||
|
||||
Mocker.SetConstant<IEnumerable<NewznabDefinition>>(new List<NewznabDefinition> { definition });
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<NewznabProvider>();
|
||||
|
||||
//Assert
|
||||
var result = db.Fetch<NewznabDefinition>();
|
||||
var result = Db.Fetch<NewznabDefinition>().Where(c => c.BuiltIn == false);
|
||||
result.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckHostname_should_do_nothing_if_hostname_is_valid()
|
||||
{
|
||||
Mocker.Resolve<NewznabProvider>().CheckHostname("http://www.google.com");
|
||||
Subject.CheckHostname("http://www.google.com");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckHostname_should_log_error_and_throw_exception_if_dnsHostname_is_invalid()
|
||||
{
|
||||
Assert.Throws<SocketException>(() => Mocker.Resolve<NewznabProvider>().CheckHostname("http://BadName"));
|
||||
Assert.Throws<SocketException>(() => Subject.CheckHostname("http://BadName"));
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<QualityTypeProvider>();
|
||||
|
||||
//Assert
|
||||
|
||||
var types = Mocker.Resolve<QualityTypeProvider>().All();
|
||||
|
||||
types.Should().HaveCount(10);
|
||||
|
@ -51,10 +51,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
|
||||
db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<QualityTypeProvider>();
|
||||
|
||||
//Assert
|
||||
|
||||
var types = Mocker.Resolve<QualityTypeProvider>().All();
|
||||
|
||||
types.Should().HaveCount(QualityTypes.All().Count - 1);
|
||||
|
@ -74,10 +74,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
|
||||
db.InsertMany(fakeQualityTypes);
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().HaveCount(ids.Count);
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
|
||||
db.InsertMany(fakeQualityTypes);
|
||||
|
||||
//Act
|
||||
|
||||
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
|
||||
|
||||
//Assert
|
||||
|
||||
result.Should().HaveCount(ids.Count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace NzbDrone.Core.Test
|
|||
Allowed = new List<QualityTypes> { QualityTypes.HDTV720p, QualityTypes.DVD },
|
||||
};
|
||||
|
||||
//Act
|
||||
|
||||
var id = Convert.ToInt32(database.Insert(testProfile));
|
||||
var fetch = database.SingleOrDefault<QualityProfile>(id);
|
||||
|
||||
//Assert
|
||||
|
||||
Assert.AreEqual(id, fetch.QualityProfileId);
|
||||
Assert.AreEqual(testProfile.Name, fetch.Name);
|
||||
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
||||
|
@ -52,11 +52,11 @@ namespace NzbDrone.Core.Test
|
|||
Cutoff = QualityTypes.SDTV
|
||||
};
|
||||
|
||||
//Act
|
||||
|
||||
var id = Convert.ToInt32(database.Insert(testProfile));
|
||||
var fetch = database.SingleOrDefault<QualityProfile>(id);
|
||||
|
||||
//Assert
|
||||
|
||||
Assert.AreEqual(id, fetch.QualityProfileId);
|
||||
Assert.AreEqual(testProfile.Name, fetch.Name);
|
||||
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
||||
|
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test
|
|||
Cutoff = QualityTypes.SDTV
|
||||
};
|
||||
|
||||
//Act
|
||||
|
||||
var id = Convert.ToInt32(db.Insert(testProfile));
|
||||
var currentProfile = db.SingleOrDefault<QualityProfile>(id);
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
var updated = Mocker.Resolve<QualityProvider>().Get(currentProfile.QualityProfileId);
|
||||
|
||||
//Assert
|
||||
|
||||
updated.Name.Should().Be(currentProfile.Name);
|
||||
updated.Cutoff.Should().Be(QualityTypes.Bluray720p);
|
||||
updated.AllowedString.Should().Be(currentProfile.AllowedString);
|
||||
|
@ -134,10 +134,10 @@ namespace NzbDrone.Core.Test
|
|||
var db = TestDbHelper.GetEmptyDatabase();
|
||||
Mocker.SetConstant(db);
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
|
||||
//Assert
|
||||
|
||||
var profiles = Mocker.Resolve<QualityProvider>().All();
|
||||
|
||||
|
||||
|
@ -157,10 +157,10 @@ namespace NzbDrone.Core.Test
|
|||
Mocker.SetConstant(db);
|
||||
var fakeProfile = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
//Act
|
||||
|
||||
Mocker.Resolve<QualityProvider>().Add(fakeProfile);
|
||||
|
||||
//Assert
|
||||
|
||||
var profiles = Mocker.Resolve<QualityProvider>().All();
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core
|
|||
public static class ContainerExtentions
|
||||
{
|
||||
|
||||
private static Logger _logger = LogManager.GetLogger("ServiceRegistration");
|
||||
private static readonly Logger _logger = LogManager.GetLogger("ServiceRegistration");
|
||||
|
||||
public static void RegisterCoreServices(this ContainerBuilder container)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
public class NewznabProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IDatabase _database;
|
||||
|
||||
public NewznabProvider(IDatabase database)
|
||||
|
@ -51,11 +51,11 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
if (definition.Id == 0)
|
||||
{
|
||||
Logger.Debug("Adding Newznab definitions for {0}", definition.Name);
|
||||
logger.Debug("Adding Newznab definitions for {0}", definition.Name);
|
||||
return Convert.ToInt32(_database.Insert(definition));
|
||||
}
|
||||
|
||||
Logger.Debug("Updating Newznab definitions for {0}", definition.Name);
|
||||
logger.Debug("Updating Newznab definitions for {0}", definition.Name);
|
||||
return _database.Update(definition);
|
||||
}
|
||||
|
||||
|
@ -75,13 +75,13 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
private void InitializeNewznabIndexers(IList<NewznabDefinition> indexers)
|
||||
{
|
||||
Logger.Debug("Initializing Newznab indexers. Count {0}", indexers.Count);
|
||||
logger.Debug("Initializing Newznab indexers. Count {0}", indexers.Count);
|
||||
|
||||
try
|
||||
{
|
||||
var currentIndexers = All();
|
||||
|
||||
Logger.Debug("Deleting broken Newznab indexer");
|
||||
logger.Debug("Deleting broken Newznab indexer");
|
||||
var brokenIndexers = currentIndexers.Where(i => String.IsNullOrEmpty(i.Name) || String.IsNullOrWhiteSpace(i.Url)).ToList();
|
||||
brokenIndexers.ForEach(e => _database.Delete<NewznabDefinition>(e.Id));
|
||||
|
||||
|
@ -120,13 +120,13 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("An error occurred while setting up indexer: " + feedProvider.Name, ex);
|
||||
logger.ErrorException("An error occurred while setting up indexer: " + feedProvider.Name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("An Error occurred while initializing Newznab Indexers", ex);
|
||||
logger.ErrorException("An Error occurred while initializing Newznab Indexers", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,8 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("Invalid address {0}, please correct the site URL.", url);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
logger.Error("Invalid address {0}, please correct the site URL.", url);
|
||||
logger.TraceException(ex.Message, ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<SolutionConfiguration>
|
||||
<FileVersion>1</FileVersion>
|
||||
<AutoEnableOnStartup>False</AutoEnableOnStartup>
|
||||
<AutoEnableOnStartup>True</AutoEnableOnStartup>
|
||||
<AllowParallelTestExecution>false</AllowParallelTestExecution>
|
||||
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
|
||||
<AllowTestsToRunInParallelWithThemselves>false</AllowTestsToRunInParallelWithThemselves>
|
||||
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
|
||||
<FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
|
||||
<FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
|
||||
<FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
|
||||
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
|
||||
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>
|
||||
<FrameworkUtilisationTypeForMSTest>Disabled</FrameworkUtilisationTypeForMSTest>
|
||||
<AdditionalFilesToInclude>NzbDrone.Web\**.*</AdditionalFilesToInclude>
|
||||
<EngineModes>Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk</EngineModes>
|
||||
<MetricsExclusionList>
|
||||
|
|
Loading…
Reference in New Issue