2012-02-05 09:34:36 +03:00
|
|
|
using System.Linq;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common.Contract;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
public class ReportingService_ReportParseError_Fixture : TestBase
|
|
|
|
{
|
|
|
|
[SetUp]
|
|
|
|
public void SetUp()
|
|
|
|
{
|
|
|
|
ReportingService.ClearCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
public void TearDown()
|
|
|
|
{
|
|
|
|
ReportingService.ClearCache();
|
|
|
|
}
|
2012-02-05 10:17:19 +03:00
|
|
|
|
2012-02-05 09:34:36 +03:00
|
|
|
[Test]
|
|
|
|
public void report_parse_error_should_send_report_to_server()
|
|
|
|
{
|
|
|
|
const string badTitle = "Bad Title";
|
|
|
|
|
|
|
|
ReportingService.ReportParseError(badTitle);
|
2012-02-05 19:53:08 +03:00
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.Is<string>(c => c.ToLower().StartsWith("http://services.nzbdrone.com/")), It.Is<ParseErrorReport>(c => c.Title == badTitle)), Times.Once());
|
2012-02-05 09:34:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void report_parse_error_should_send_duplicated_report_once()
|
|
|
|
{
|
|
|
|
const string badTitle = "Bad Title";
|
|
|
|
|
|
|
|
ReportingService.ReportParseError(badTitle);
|
|
|
|
ReportingService.ReportParseError(badTitle);
|
|
|
|
|
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.IsAny<ReportBase>()), Times.Once());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void report_parse_error_should_send_duplicated_report_once_with_diffrent_casing()
|
|
|
|
{
|
|
|
|
const string badTitle = "Bad Title";
|
|
|
|
|
|
|
|
ReportingService.ReportParseError(badTitle.ToUpper());
|
|
|
|
ReportingService.ReportParseError(badTitle);
|
|
|
|
|
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.IsAny<ReportBase>()), Times.Once());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void report_parse_error_should_send_multiple_reports_if_titles_are_diffrent()
|
|
|
|
{
|
|
|
|
ReportingService.ReportParseError("title 1");
|
|
|
|
ReportingService.ReportParseError("title 2");
|
|
|
|
|
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.IsAny<ReportBase>()), Times.Exactly(2));
|
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.Is<ParseErrorReport>(c => c.Title == "title 1")), Times.Once());
|
|
|
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.Is<ParseErrorReport>(c => c.Title == "title 2")), Times.Once());
|
|
|
|
}
|
|
|
|
|
2012-02-05 19:53:08 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void report_parse_error()
|
|
|
|
{
|
2012-03-07 05:59:43 +03:00
|
|
|
ReportingService.RestProvider = new RestProvider(new EnvironmentProvider());
|
2012-02-05 19:53:08 +03:00
|
|
|
ReportingService.ReportParseError("Test error");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-05 09:34:36 +03:00
|
|
|
}
|
|
|
|
}
|