From 54dc8ee35ed89660dae088d2e832f8b19c577801 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 23 Feb 2013 10:02:58 -0800 Subject: [PATCH] Removed strict mocker from available update tests, for real this time.... --- NzbDrone.Common/HttpProvider.cs | 6 +++++- .../UpdateProviderTests/GetAvilableUpdateFixture.cs | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Common/HttpProvider.cs b/NzbDrone.Common/HttpProvider.cs index 04c7a074f..22b12dcef 100644 --- a/NzbDrone.Common/HttpProvider.cs +++ b/NzbDrone.Common/HttpProvider.cs @@ -12,10 +12,12 @@ namespace NzbDrone.Common { private readonly EnvironmentProvider _environmentProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); + private readonly string _userAgent; public HttpProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; + _userAgent = String.Format("NzbDrone {0}", _environmentProvider.Version); } public HttpProvider() @@ -37,6 +39,7 @@ namespace NzbDrone.Common try { var client = new WebClient { Credentials = identity }; + client.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); return client.DownloadString(address); } catch (Exception ex) @@ -49,7 +52,7 @@ namespace NzbDrone.Common public virtual Stream DownloadStream(string url, NetworkCredential credential) { var request = (HttpWebRequest)WebRequest.Create(url); - request.UserAgent = String.Format("NzbDrone {0}", _environmentProvider.Version); + request.UserAgent = _userAgent; request.Credentials = credential; var response = request.GetResponse(); @@ -71,6 +74,7 @@ namespace NzbDrone.Common var stopWatch = Stopwatch.StartNew(); var webClient = new WebClient(); + webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); webClient.DownloadFile(url, fileName); stopWatch.Stop(); logger.Trace("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs index f4cd2c542..a5db3d655 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs @@ -20,8 +20,6 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests [SetUp] public void Setup() { - WithStrictMocker(); - Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/"); Mocker.Resolve(); }