From ba634b75d6c65f8832d37603c9ff079a687167af Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Wed, 18 Sep 2013 17:25:34 -0700 Subject: [PATCH] delete old Reporting code. --- NzbDrone.Common/Contract/ParseErrorReport.cs | 21 ------- NzbDrone.Common/Contract/ReportBase.cs | 31 ---------- NzbDrone.Common/NzbDrone.Common.csproj | 3 - NzbDrone.Common/RestProvider.cs | 60 ------------------- .../ParserTests/ParserFixture.cs | 12 ---- NzbDrone.Test.Common/TestBase.cs | 4 -- 6 files changed, 131 deletions(-) delete mode 100644 NzbDrone.Common/Contract/ParseErrorReport.cs delete mode 100644 NzbDrone.Common/Contract/ReportBase.cs delete mode 100644 NzbDrone.Common/RestProvider.cs diff --git a/NzbDrone.Common/Contract/ParseErrorReport.cs b/NzbDrone.Common/Contract/ParseErrorReport.cs deleted file mode 100644 index fe78111e6..000000000 --- a/NzbDrone.Common/Contract/ParseErrorReport.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace NzbDrone.Common.Contract -{ - public class ParseErrorReport : ReportBase - { - [JsonProperty("t")] - public string Title { get; set; } - - protected override Dictionary GetString() - { - var dic = new Dictionary - { - {"Title", Title.NullSafe()}, - }; - - return dic; - } - } -} diff --git a/NzbDrone.Common/Contract/ReportBase.cs b/NzbDrone.Common/Contract/ReportBase.cs deleted file mode 100644 index 559a3a847..000000000 --- a/NzbDrone.Common/Contract/ReportBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace NzbDrone.Common.Contract -{ - public abstract class ReportBase - { - [JsonProperty("v")] - public string Version { get; set; } - - [JsonProperty("p")] - public bool IsProduction { get; set; } - - [JsonProperty("u")] - public Guid UGuid { get; set; } - - public override string ToString() - { - var childString = ""; - foreach (var keyValue in GetString()) - { - childString += string.Format("{0}: {1} ", keyValue.Key, keyValue.Value); - } - - return string.Format("[{0} Prd:{1} V:{2} ID:{3} | {4}]", GetType().Name, IsProduction, Version, UGuid, childString.Trim()); - } - - protected abstract Dictionary GetString(); - } -} diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index f1899c2b5..8fe4ab3af 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -118,8 +118,6 @@ - - @@ -127,7 +125,6 @@ - diff --git a/NzbDrone.Common/RestProvider.cs b/NzbDrone.Common/RestProvider.cs deleted file mode 100644 index 6964d4b87..000000000 --- a/NzbDrone.Common/RestProvider.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.IO; -using System.Net; -using System.Text; -using NzbDrone.Common.Contract; -using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Common.Serializer; - -namespace NzbDrone.Common -{ - - public class RestProvider - { - private const int TIMEOUT = 15000; - private const string METHOD = "POST"; - - public virtual void PostData(string url, ReportBase reportBase) - { - reportBase.Version = BuildInfo.Version.ToString(); - reportBase.IsProduction = RuntimeInfo.IsProduction; - - PostData(url, reportBase as object); - } - - - private static void PostData(string url, object message) - { - try - { - var json = message.ToJson(); - - var request = (HttpWebRequest)WebRequest.Create(url); - request.Timeout = TIMEOUT; - - request.Proxy = WebRequest.DefaultWebProxy; - - request.KeepAlive = false; - request.ProtocolVersion = HttpVersion.Version10; - request.Method = METHOD; - request.ContentType = "application/json"; - - byte[] postBytes = Encoding.UTF8.GetBytes(json); - request.ContentLength = postBytes.Length; - - var requestStream = request.GetRequestStream(); - requestStream.Write(postBytes, 0, postBytes.Length); - requestStream.Close(); - - var response = (HttpWebResponse)request.GetResponse(); - var streamreader = new StreamReader(response.GetResponseStream()); - streamreader.Close(); - } - catch (Exception e) - { - e.Data.Add("URL", url); - throw; - } - } - } -} diff --git a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index ace78f50e..d74c5aedf 100644 --- a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -3,7 +3,6 @@ using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Common.Contract; using NzbDrone.Common.Expansive; using NzbDrone.Core.Parser; using NzbDrone.Core.Test.Framework; @@ -116,17 +115,6 @@ namespace NzbDrone.Core.Test.ParserTests ExceptionVerification.IgnoreWarns(); } - [Test] - [Ignore] - public void unparsable_path_should_report_the_path() - { - Parser.Parser.ParsePath("C:\\SOMETHING 12345.avi").Should().BeNull(); - - MockedRestProvider.Verify(c => c.PostData(It.IsAny(), It.IsAny()), Times.Exactly(2)); - - ExceptionVerification.IgnoreWarns(); - } - [TestCase("[DmonHiro] The Severing Crime Edge - Cut 02 - Portrait Of Heresy [BD, 720p] [BE36E9E0]")] public void unparsable_title_should_log_warn_and_return_null(string title) { diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 82e73ab4d..92d34a15d 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -9,7 +9,6 @@ using NzbDrone.Common; using NzbDrone.Common.Cache; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Messaging; -using NzbDrone.Core.Messaging; using NzbDrone.Core.Messaging.Events; using NzbDrone.Test.Common.AutoMoq; @@ -62,7 +61,6 @@ namespace NzbDrone.Test.Common } } - protected Mock MockedRestProvider { get; private set; } protected int RandomNumber { @@ -102,8 +100,6 @@ namespace NzbDrone.Test.Common TempFolder = Path.Combine(Directory.GetCurrentDirectory(), "_temp_" + DateTime.Now.Ticks); - MockedRestProvider = new Mock(); - Directory.CreateDirectory(TempFolder); }