Fixed tests/null reference for import lists
This commit is contained in:
parent
b2b1600ebe
commit
a92665c5cd
|
@ -1,7 +1,9 @@
|
||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.ImportLists;
|
||||||
using NzbDrone.Core.Lifecycle;
|
using NzbDrone.Core.Lifecycle;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
@ -13,6 +15,14 @@ namespace NzbDrone.Core.Test.Languages
|
||||||
|
|
||||||
public class LanguageProfileServiceFixture : CoreTest<LanguageProfileService>
|
public class LanguageProfileServiceFixture : CoreTest<LanguageProfileService>
|
||||||
{
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IImportListFactory>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(new List<ImportListDefinition>());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void init_should_add_default_profiles()
|
public void init_should_add_default_profiles()
|
||||||
{
|
{
|
||||||
|
@ -52,10 +62,8 @@ namespace NzbDrone.Core.Test.Languages
|
||||||
Assert.Throws<LanguageProfileInUseException>(() => Subject.Delete(2));
|
Assert.Throws<LanguageProfileInUseException>(() => Subject.Delete(2));
|
||||||
|
|
||||||
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_profile_if_not_assigned_to_series()
|
public void should_delete_profile_if_not_assigned_to_series()
|
||||||
{
|
{
|
||||||
|
@ -71,5 +79,31 @@ namespace NzbDrone.Core.Test.Languages
|
||||||
|
|
||||||
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_be_able_to_delete_profile_if_assigned_to_import_list()
|
||||||
|
{
|
||||||
|
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||||
|
.Random(1)
|
||||||
|
.With(c => c.LanguageProfileId = 2)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
var importLists = Builder<ImportListDefinition>.CreateListOfSize(3)
|
||||||
|
.Random(1)
|
||||||
|
.With(c => c.LanguageProfileId = 1)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||||
|
|
||||||
|
Mocker.GetMock<IImportListFactory>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(importLists);
|
||||||
|
|
||||||
|
Assert.Throws<LanguageProfileInUseException>(() => Subject.Delete(1));
|
||||||
|
|
||||||
|
Mocker.GetMock<ILanguageProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.ImportLists;
|
||||||
using NzbDrone.Core.Lifecycle;
|
using NzbDrone.Core.Lifecycle;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
@ -10,8 +12,16 @@ using NzbDrone.Core.Tv;
|
||||||
namespace NzbDrone.Core.Test.Profiles
|
namespace NzbDrone.Core.Test.Profiles
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ProfileServiceFixture : CoreTest<QualityProfileService>
|
public class QualityProfileServiceFixture : CoreTest<QualityProfileService>
|
||||||
{
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IImportListFactory>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(new List<ImportListDefinition>());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void init_should_add_default_profiles()
|
public void init_should_add_default_profiles()
|
||||||
{
|
{
|
||||||
|
@ -56,10 +66,8 @@ namespace NzbDrone.Core.Test.Profiles
|
||||||
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
|
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
|
||||||
|
|
||||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_profile_if_not_assigned_to_series()
|
public void should_delete_profile_if_not_assigned_to_series()
|
||||||
{
|
{
|
||||||
|
@ -75,5 +83,36 @@ namespace NzbDrone.Core.Test.Profiles
|
||||||
|
|
||||||
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_be_able_to_delete_profile_if_assigned_to_import_list()
|
||||||
|
{
|
||||||
|
var profile = Builder<QualityProfile>.CreateNew()
|
||||||
|
.With(p => p.Id = 1)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var seriesList = Builder<Series>.CreateListOfSize(3)
|
||||||
|
.All()
|
||||||
|
.With(c => c.QualityProfileId = 2)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
var importLists = Builder<ImportListDefinition>.CreateListOfSize(3)
|
||||||
|
.Random(1)
|
||||||
|
.With(c => c.LanguageProfileId = 1)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
|
||||||
|
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
|
||||||
|
|
||||||
|
Mocker.GetMock<IImportListFactory>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(importLists);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(1));
|
||||||
|
|
||||||
|
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -86,8 +86,12 @@ namespace NzbDrone.Core.ImportLists
|
||||||
{
|
{
|
||||||
var mappedSeries = _seriesSearchService.SearchForNewSeries(report.Title)
|
var mappedSeries = _seriesSearchService.SearchForNewSeries(report.Title)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
report.TvdbId = mappedSeries.TvdbId;
|
|
||||||
report.Title = mappedSeries?.Title;
|
if (mappedSeries != null)
|
||||||
|
{
|
||||||
|
report.TvdbId = mappedSeries.TvdbId;
|
||||||
|
report.Title = mappedSeries?.Title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if series in DB
|
// Check to see if series in DB
|
||||||
|
|
Loading…
Reference in New Issue