2012-02-07 06:08:07 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
2013-01-03 02:09:13 +01:00
|
|
|
|
using Autofac;
|
2012-02-04 06:28:50 +01:00
|
|
|
|
using FluentAssertions;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using NLog;
|
2012-02-04 06:28:50 +01:00
|
|
|
|
using NUnit.Framework;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using NzbDrone.Common;
|
2013-01-03 02:09:13 +01:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
2012-02-04 06:28:50 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using PetaPoco;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Integeration
|
|
|
|
|
{
|
|
|
|
|
[TestFixture(Category = "ServiceIngeneration")]
|
|
|
|
|
public class ServiceIntegerationFixture : CoreTest
|
|
|
|
|
{
|
2013-01-03 02:09:13 +01:00
|
|
|
|
private IContainer _container;
|
2012-02-04 06:28:50 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
WithRealDb();
|
2013-01-03 02:09:13 +01:00
|
|
|
|
var builder = new CentralDispatch().ContainerBuilder;
|
|
|
|
|
|
|
|
|
|
builder.Register(c => Db)
|
|
|
|
|
.As<IDatabase>();
|
|
|
|
|
|
|
|
|
|
_container = builder.Build();
|
2012-02-04 06:28:50 +01:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
|
2012-04-14 02:57:31 +02:00
|
|
|
|
.Returns("http://services.nzbdrone.com");
|
2012-02-04 06:28:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_able_to_update_scene_mapping()
|
|
|
|
|
{
|
2013-01-03 02:09:13 +01:00
|
|
|
|
_container.Resolve<SceneMappingProvider>().UpdateMappings();
|
2012-02-04 06:28:50 +01:00
|
|
|
|
var mappings = Db.Fetch<SceneMapping>();
|
|
|
|
|
|
|
|
|
|
mappings.Should().NotBeEmpty();
|
|
|
|
|
|
|
|
|
|
mappings.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.CleanTitle));
|
|
|
|
|
mappings.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.SceneName));
|
|
|
|
|
mappings.Should().OnlyContain(c => c.SeriesId > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_able_to_get_daily_series_ids()
|
|
|
|
|
{
|
2013-01-03 02:09:13 +01:00
|
|
|
|
var dailySeries = _container.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
2012-02-04 06:28:50 +01:00
|
|
|
|
|
|
|
|
|
dailySeries.Should().NotBeEmpty();
|
|
|
|
|
dailySeries.Should().OnlyContain(c => c > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-02-07 06:08:07 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_be_able_to_submit_exceptions()
|
|
|
|
|
{
|
2012-04-30 03:24:24 +02:00
|
|
|
|
ReportingService.SetupExceptronDriver();
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
2012-04-30 03:24:24 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ThrowException();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
var log = new LogEventInfo
|
|
|
|
|
{
|
|
|
|
|
LoggerName = "LoggerName.LoggerName.LoggerName.LoggerName",
|
|
|
|
|
Exception = e,
|
|
|
|
|
Message = "New message string. New message string.",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var hash = ReportingService.ReportException(log);
|
|
|
|
|
|
|
|
|
|
hash.Should().HaveLength(8);
|
|
|
|
|
}
|
2012-02-07 06:08:07 +01:00
|
|
|
|
}
|
2012-02-04 06:28:50 +01:00
|
|
|
|
}
|
|
|
|
|
}
|