From 969c36912d6d6227f34dcea7f5edf7bf4188e197 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Wed, 29 Feb 2012 23:58:11 -0800 Subject: [PATCH] Added uguid to exceptioninstance --- .../Controllers/ExceptionController.cs | 4 +++- .../Migrations/Migration20120229.cs | 1 + .../Repository/Reporting/ExceptionInstance.cs | 1 + .../ReportExistingFixture.cs | 14 +++++++++++--- .../ExceptionControllerTests/ReportNewFixture.cs | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs b/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs index 725b68eb2..2e3cb9fab 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Controllers/ExceptionController.cs @@ -33,6 +33,7 @@ namespace NzbDrone.Services.Service.Controllers ExceptionHash = existingExceptionReport.Hash, IsProduction = existingExceptionReport.IsProduction, LogMessage = existingExceptionReport.LogMessage, + UGuid = existingExceptionReport.UGuid, Timestamp = DateTime.Now }; @@ -64,7 +65,8 @@ namespace NzbDrone.Services.Service.Controllers ExceptionHash = exceptionHash, IsProduction = exceptionReport.IsProduction, LogMessage = exceptionReport.LogMessage, - Timestamp = DateTime.Now + Timestamp = DateTime.Now, + UGuid = exceptionReport.UGuid }; _database.Insert(exceptionInstance); diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20120229.cs b/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20120229.cs index edb1419bb..751a82372 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20120229.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20120229.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Services.Service.Migrations new Column("ExceptionHash", DbType.String, ColumnProperty.NotNull), new Column("LogMessage", DbType.String, 3000, ColumnProperty.NotNull), MigrationsHelper.TimestampColumn, + MigrationsHelper.UGuidColumn, MigrationsHelper.ProductionColumn); Database.AddTable("Exceptions", new Column("Hash", DbType.String, ColumnProperty.Unique), diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Repository/Reporting/ExceptionInstance.cs b/NzbDrone.Services/NzbDrone.Services.Service/Repository/Reporting/ExceptionInstance.cs index 9d2e4a217..083243370 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Repository/Reporting/ExceptionInstance.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Repository/Reporting/ExceptionInstance.cs @@ -12,5 +12,6 @@ namespace NzbDrone.Services.Service.Repository.Reporting public string LogMessage { get; set; } public DateTime Timestamp { get; set; } public bool IsProduction { get; set; } + public Guid UGuid { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs index fe16b03f3..87cdd26c2 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs +++ b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportExistingFixture.cs @@ -53,13 +53,21 @@ namespace NzbDrone.Services.Tests.ExceptionControllerTests WithRealDb(); var existing = CreateExceptionReport(); + Db.Insert(Builder.CreateNew().With(c => c.Hash = existing.Hash).Build()); - - Controller.ReportExisting(CreateExceptionReport()); + + Controller.ReportExisting(existing); Db.Fetch().Should().HaveCount(1); - Db.Fetch().Should().HaveCount(1); + var exceptionInstance = Db.Fetch(); + exceptionInstance.Should().HaveCount(1); + exceptionInstance.Single().Id.Should().BeGreaterThan(0); + exceptionInstance.Single().ExceptionHash.Should().NotBeBlank(); + exceptionInstance.Single().IsProduction.Should().Be(existing.IsProduction); + exceptionInstance.Single().Timestamp.Should().BeWithin(TimeSpan.FromSeconds(4)).Before(DateTime.Now); + exceptionInstance.Single().LogMessage.Should().Be(existing.LogMessage); + exceptionInstance.Single().UGuid.Should().Be(existing.UGuid); } } diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs index a2658b0ef..2e96d18b4 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs +++ b/NzbDrone.Services/NzbDrone.Services.Tests/ExceptionControllerTests/ReportNewFixture.cs @@ -92,6 +92,7 @@ namespace NzbDrone.Services.Tests.ExceptionControllerTests exceptionInstance.Single().IsProduction.Should().Be(exceptionReport.IsProduction); exceptionInstance.Single().Timestamp.Should().BeWithin(TimeSpan.FromSeconds(4)).Before(DateTime.Now); exceptionInstance.Single().LogMessage.Should().Be(exceptionReport.LogMessage); + exceptionInstance.Single().UGuid.Should().Be(exceptionReport.UGuid); } [Test]