From d8418b35e1706dcad6a5a475581e481b2db7c492 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Wed, 29 Feb 2012 22:45:36 -0800 Subject: [PATCH] Fixed broken service tests. --- NzbDrone.Common/ReportingService.cs | 2 +- .../Controllers/ExceptionController.cs | 2 ++ .../ReportExistingFixture.cs | 2 +- .../ReportNewFixture.cs | 2 +- .../NzbDrone.Services.Tests.csproj | 4 +-- .../ReportingControllerFixture.cs | 31 ++++--------------- 6 files changed, 13 insertions(+), 30 deletions(-) rename NzbDrone.Services/NzbDrone.Services.Tests/{ExceptionController => ExceptionControllerTests}/ReportExistingFixture.cs (96%) rename NzbDrone.Services/NzbDrone.Services.Tests/{ExceptionController => ExceptionControllerTests}/ReportNewFixture.cs (99%) diff --git a/NzbDrone.Common/ReportingService.cs b/NzbDrone.Common/ReportingService.cs index 0ab413e17..7faf928b2 100644 --- a/NzbDrone.Common/ReportingService.cs +++ b/NzbDrone.Common/ReportingService.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Common { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - private const string SERVICE_URL = "http://services.nzbdrone.com/reporting"; + private const string SERVICE_URL = "http://stage.services.nzbdrone.com/reporting"; private const string PARSE_URL = SERVICE_URL + "/ParseError"; private const string EXCEPTION_URL = SERVICE_URL + "/ReportException"; diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs b/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs index 11c119b60..725b68eb2 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Web.Mvc; using NLog; +using Ninject; using NzbDrone.Common.Contract; using NzbDrone.Services.Service.Repository.Reporting; using Services.PetaPoco; @@ -13,6 +14,7 @@ namespace NzbDrone.Services.Service.Controllers private readonly IDatabase _database; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); + [Inject] public ExceptionController(IDatabase database) { _database = database; diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportExistingFixture.cs b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs similarity index 96% rename from NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportExistingFixture.cs rename to NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs index 00e92b737..fe16b03f3 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportExistingFixture.cs +++ b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Services.Service.Repository.Reporting; using NzbDrone.Services.Tests.Framework; using NzbDrone.Test.Common; -namespace NzbDrone.Services.Tests.ExceptionController +namespace NzbDrone.Services.Tests.ExceptionControllerTests { [TestFixture] public class ReportExistingFixture : ServicesTestBase diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportNewFixture.cs b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs similarity index 99% rename from NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportNewFixture.cs rename to NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs index 1d872d6aa..a2658b0ef 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionController/ReportNewFixture.cs +++ b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs @@ -6,7 +6,7 @@ using NzbDrone.Common.Contract; using NzbDrone.Services.Service.Repository.Reporting; using NzbDrone.Services.Tests.Framework; -namespace NzbDrone.Services.Tests.ExceptionController +namespace NzbDrone.Services.Tests.ExceptionControllerTests { [TestFixture] public class ReportNewFixture : ServicesTestBase diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj index 11bf63b31..7f757d47d 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj +++ b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj @@ -68,8 +68,8 @@ - - + + diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/ReportingControllerFixture.cs b/NzbDrone.Services/NzbDrone.Services.Tests/ReportingControllerFixture.cs index c8da31737..62896b43c 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/ReportingControllerFixture.cs +++ b/NzbDrone.Services/NzbDrone.Services.Tests/ReportingControllerFixture.cs @@ -12,6 +12,12 @@ namespace NzbDrone.Services.Tests [TestFixture] public class ReportingControllerFixture : ServicesTestBase { + [SetUp] + public void Setup() + { + WithRealDb(); + Mocker.Resolve(); + } ReportingController Controller { @@ -94,7 +100,6 @@ namespace NzbDrone.Services.Tests { var parseReport = CreateParseErrorReport(); - WithRealDb(); Controller.ParseError(parseReport); @@ -115,7 +120,6 @@ namespace NzbDrone.Services.Tests parseReport1.Title = Guid.NewGuid().ToString(); - WithRealDb(); Controller.ParseError(parseReport1); Controller.ParseError(parseReport2); @@ -130,7 +134,6 @@ namespace NzbDrone.Services.Tests var parseReport1 = CreateParseErrorReport(); var parseReport2 = CreateParseErrorReport(); - WithRealDb(); Controller.ParseError(parseReport1); Controller.ParseError(parseReport2); @@ -138,27 +141,5 @@ namespace NzbDrone.Services.Tests var reports = Db.Fetch(); reports.Should().HaveCount(1); } - - [Test] - public void exception_report_should_be_saved() - { - var exceptionReport = CreateExceptionReport(); - - WithRealDb(); - - Controller.ReportException(exceptionReport); - - var exceptionRows = Db.Fetch(); - exceptionRows.Should().HaveCount(1); - exceptionRows.Single().IsProduction.Should().Be(exceptionReport.IsProduction); - exceptionRows.Single().Version.Should().Be(exceptionReport.Version); - exceptionRows.Single().Timestamp.Should().BeWithin(TimeSpan.FromSeconds(4)).Before(DateTime.Now); - exceptionRows.Single().UGuid.Should().Be(exceptionReport.UGuid); - - exceptionRows.Single().Logger.Should().Be(exceptionReport.Logger); - exceptionRows.Single().LogMessage.Should().Be(exceptionReport.LogMessage); - exceptionRows.Single().String.Should().Be(exceptionReport.String); - exceptionRows.Single().Type.Should().Be(exceptionReport.Type); - } } }