diff --git a/NzbDrone.Backbone/NzbDrone.Backbone.csproj b/NzbDrone.Backbone/NzbDrone.Backbone.csproj index 8bc32cadc..1fee04247 100644 --- a/NzbDrone.Backbone/NzbDrone.Backbone.csproj +++ b/NzbDrone.Backbone/NzbDrone.Backbone.csproj @@ -80,9 +80,9 @@ - True + False True - 0 + 12766 / http://localhost:55352/ False diff --git a/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs index c40467cd2..fa7e33a93 100644 --- a/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -31,10 +31,10 @@ namespace NzbDrone.Common.Test const string key = "Port"; const string value = "8989"; - //Act + var result = Mocker.Resolve().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().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().GetValueBoolean(key, value); - //Assert + result.Should().BeTrue(); } [Test] public void GetLaunchBrowser_Success() { - //Act + var result = Mocker.Resolve().LaunchBrowser; - //Assert + result.Should().Be(true); } @@ -79,10 +79,10 @@ namespace NzbDrone.Common.Test { const int value = 8989; - //Act + var result = Mocker.Resolve().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().SetValue(key, value); - //Assert + var result = Mocker.Resolve().LaunchBrowser; result.Should().Be(value); } @@ -106,10 +106,10 @@ namespace NzbDrone.Common.Test const string key = "Port"; const int value = 12345; - //Act + Mocker.Resolve().SetValue(key, value); - //Assert + var result = Mocker.Resolve().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().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().AuthenticationType; - //Assert + result.Should().Be(AuthenticationType.Anonymous); } @@ -144,22 +144,22 @@ namespace NzbDrone.Common.Test Mocker.Resolve().SetValue("AuthenticationType", 1); - //Act + var result = Mocker.Resolve().AuthenticationType; - //Assert + result.Should().Be(AuthenticationType.Windows); } [Test] public void Guid_should_return_the_same_every_time() { - //Act + var firstResponse = Mocker.Resolve().Guid; var secondResponse = Mocker.Resolve().Guid; - //Assert + secondResponse.Should().Be(firstResponse); } } diff --git a/NzbDrone.Core.Test/Framework/CoreTest.cs b/NzbDrone.Core.Test/Framework/CoreTest.cs index 3bd7f899b..14bbe9828 100644 --- a/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -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(); } diff --git a/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs b/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs new file mode 100644 index 000000000..aee497093 --- /dev/null +++ b/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs @@ -0,0 +1,29 @@ +namespace NzbDrone.Core.Test.Framework +{ + public abstract class CoreTest : CoreTest where TSubject : class + { + + private TSubject _subject; + + + protected TSubject Subject + { + get + { + if (_subject == null) + { + _subject = Mocker.Resolve(); + } + + return _subject; + + } + } + + + protected void InitiateSubject() + { + _subject = Mocker.Resolve(); + } + } +} diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 837e3d9aa..3c69d05e3 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -138,6 +138,7 @@ + diff --git a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs index 9a88fff58..c76057a04 100644 --- a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.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(); - //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(); - //Assert + indexerProvider.All(); indexerProvider.All().Should().HaveCount(1); indexerProvider.GetEnabledIndexers().Should().HaveCount(0); diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index f9b605149..8004685c5 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -71,12 +71,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); - //Act + ResetLastExecution(); Mocker.Resolve().QueueScheduled(); WaitForQueue(); - //Assert + var settings = Mocker.Resolve().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 BaseFakeJobs = new List { brokenJob }; Mocker.SetConstant(BaseFakeJobs); - //Act + ResetLastExecution(); Mocker.Resolve().QueueScheduled(); WaitForQueue(); - //Assert + var settings = Mocker.Resolve().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 BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); - //Act + ResetLastExecution(); Mocker.Resolve().QueueScheduled(); @@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests Mocker.Resolve().QueueScheduled(); WaitForQueue(); - //Assert + fakeJob.ExecutionCount.Should().Be(1); } @@ -131,13 +131,13 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests var jobProvider = Mocker.Resolve(); - //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(); - //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(); - //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(); - //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(); + Mocker.Resolve(); } var Mocker2 = new AutoMoqer(); @@ -270,7 +270,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests var assertjobProvider = Mocker2.Resolve(); 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(); - //Assert + var registeredJobs = Db.Fetch(); 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(); - //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 BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); - //Act + var jobProvider = Mocker.Resolve(); 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 BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); - //Act + var jobProvider = Mocker.Resolve(); 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.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); } diff --git a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs index e53d4daa4..1111b365b 100644 --- a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs @@ -14,93 +14,64 @@ namespace NzbDrone.Core.Test.ProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class NewznabProviderTest : CoreTest + public class NewznabProviderTest : CoreTest { + [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().Save(newznab); + var result = Subject.Save(newznab); - //Assert - db.Single(result).Url.Should().Be(expectedUrl); + Db.Single(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().Save(newznab); - - //Assert - db.Single(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().Save(newznab); - //Assert - db.Single(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().Save(newznab); - - //Assert - db.Single(result).Url.Should().Be(expectedUrl); + Db.Single(result).Url.Should().Be(""); } [Test] [Ignore("No longer clean newznab URLs")] public void SaveAll_should_clean_urls_before_updating() { - //Setup + var definitions = Builder.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().SaveAll(definitions); - //Assert - db.Fetch().Where(d => d.Url == expectedUrl).Should().HaveCount(5); + Subject.SaveAll(definitions); + + + Db.Fetch().Where(d => d.Url == expectedUrl).Should().HaveCount(5); } [Test] public void Enabled_should_return_all_enabled_newznab_providers() { - //Setup + var definitions = Builder.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().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.CreateListOfSize(5) - .TheFirst(2) - .With(d => d.Enable = false) - .TheLast(3) - .With(d => d.Enable = true) + + var userIndexers = Builder.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().All(); + var result = Subject.All(); + + result.Should().HaveCount(8); + } + + + [Test] + public void All_should_return_empty_list_when_no_indexers_exist() + { + Db.Delete(""); + + 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.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().Delete(1); - - //Assert - var result = db.Fetch(); - 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.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>(definitions); - - //Act - Mocker.Resolve(); - - //Assert - var result = db.Fetch(); - 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.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>(definitions); - //Act - Mocker.Resolve(); - - //Assert - var result = db.Fetch(); - result.Should().HaveCount(2); + var result = Db.Fetch(); 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.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>(new List { definition }); - - //Act - Mocker.Resolve(); - - //Assert - var result = db.Fetch(); - 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.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>(new List { definition }); - - //Act - Mocker.Resolve(); - - //Assert - var result = db.Fetch(); + var result = Db.Fetch().Where(c => c.BuiltIn == false); result.Should().HaveCount(2); } [Test] public void CheckHostname_should_do_nothing_if_hostname_is_valid() { - Mocker.Resolve().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(() => Mocker.Resolve().CheckHostname("http://BadName")); + Assert.Throws(() => Subject.CheckHostname("http://BadName")); ExceptionVerification.ExpectedErrors(1); } diff --git a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs index 6242c10cb..211c7078a 100644 --- a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs @@ -23,10 +23,10 @@ namespace NzbDrone.Core.Test.ProviderTests var db = TestDbHelper.GetEmptyDatabase(); Mocker.SetConstant(db); - //Act + Mocker.Resolve(); - //Assert + var types = Mocker.Resolve().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(); - //Assert + var types = Mocker.Resolve().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().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().GetList(ids); - //Assert + result.Should().HaveCount(ids.Count); } } diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index f38ff96be..8c13a0677 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -29,11 +29,11 @@ namespace NzbDrone.Core.Test Allowed = new List { QualityTypes.HDTV720p, QualityTypes.DVD }, }; - //Act + var id = Convert.ToInt32(database.Insert(testProfile)); var fetch = database.SingleOrDefault(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(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(id); @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test var updated = Mocker.Resolve().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(); - //Assert + var profiles = Mocker.Resolve().All(); @@ -157,10 +157,10 @@ namespace NzbDrone.Core.Test Mocker.SetConstant(db); var fakeProfile = Builder.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List { QualityTypes.SDTV, QualityTypes.DVD }).Build(); - //Act + Mocker.Resolve().Add(fakeProfile); - //Assert + var profiles = Mocker.Resolve().All(); diff --git a/NzbDrone.Core/ContainerExtentions.cs b/NzbDrone.Core/ContainerExtentions.cs index a3ab7b4d7..22960f641 100644 --- a/NzbDrone.Core/ContainerExtentions.cs +++ b/NzbDrone.Core/ContainerExtentions.cs @@ -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) { diff --git a/NzbDrone.Core/Providers/NewznabProvider.cs b/NzbDrone.Core/Providers/NewznabProvider.cs index cd3642aaf..e3957ba81 100644 --- a/NzbDrone.Core/Providers/NewznabProvider.cs +++ b/NzbDrone.Core/Providers/NewznabProvider.cs @@ -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 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(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; } diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution index acbb579d2..659c51903 100644 --- a/NzbDrone.ncrunchsolution +++ b/NzbDrone.ncrunchsolution @@ -1,12 +1,12 @@ 1 - False + True false - true + false UseDynamicAnalysis - UseStaticAnalysis - UseStaticAnalysis - UseStaticAnalysis + Disabled + Disabled + Disabled NzbDrone.Web\**.* 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