2011-06-03 03:15:02 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2011-06-14 04:15:55 +02:00
|
|
|
|
using System.Linq.Expressions;
|
2011-06-03 03:15:02 +02:00
|
|
|
|
using System.Text;
|
2011-06-14 04:15:55 +02:00
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-03 03:15:02 +02:00
|
|
|
|
using FluentAssertions;
|
2011-06-14 04:15:55 +02:00
|
|
|
|
using Moq;
|
2011-06-03 03:15:02 +02:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Helpers;
|
2011-06-14 04:15:55 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-06-03 03:15:02 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-06-14 04:15:55 +02:00
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
using TvdbLib.Data;
|
2011-06-03 03:15:02 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-06-17 08:04:01 +02:00
|
|
|
|
public class SceneMappingTest : TestBase
|
2011-06-03 03:15:02 +02:00
|
|
|
|
{
|
2011-06-14 04:15:55 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetSceneName_exists()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
|
|
|
|
.With(f => f.CleanTitle = "laworder")
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
|
|
|
|
}
|
2011-06-03 03:15:02 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
2011-06-14 04:15:55 +02:00
|
|
|
|
public void GetSeriesId_exists()
|
2011-06-03 03:15:02 +02:00
|
|
|
|
{
|
2011-06-14 04:15:55 +02:00
|
|
|
|
//Setup
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
|
|
|
|
.With(f => f.SceneName = "laworder")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
2011-06-03 03:15:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-14 04:15:55 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetSceneName_null()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
2011-06-17 08:04:01 +02:00
|
|
|
|
.With(f => f.SceneName = "laworder")
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(null, sceneName);
|
|
|
|
|
}
|
2011-06-03 03:15:02 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
2011-06-14 04:15:55 +02:00
|
|
|
|
public void GetSeriesId_null()
|
2011-06-03 03:15:02 +02:00
|
|
|
|
{
|
2011-06-14 04:15:55 +02:00
|
|
|
|
//Setup
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
2011-06-17 08:04:01 +02:00
|
|
|
|
.With(f => f.CleanTitle = "laworder")
|
2011-06-14 04:15:55 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-06-17 08:04:01 +02:00
|
|
|
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
|
2011-06-14 04:15:55 +02:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(null, seriesId);
|
2011-06-03 03:15:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|