2013-02-27 06:19:22 +03:00
|
|
|
using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
2013-04-13 02:28:05 +03:00
|
|
|
using NzbDrone.Core.Lifecycle;
|
2013-02-27 06:19:22 +03:00
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Qualities
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2013-03-29 01:07:09 +03:00
|
|
|
|
2013-02-27 06:19:22 +03:00
|
|
|
public class QualityProfileFixture : CoreTest<QualityProfileService>
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void Init_should_add_two_profiles()
|
|
|
|
{
|
2013-04-13 02:28:05 +03:00
|
|
|
Subject.Handle(new ApplicationStartedEvent());
|
2013-02-27 06:19:22 +03:00
|
|
|
|
|
|
|
Mocker.GetMock<IQualityProfileRepository>()
|
|
|
|
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
//This confirms that new profiles are added only if no other profiles exists.
|
|
|
|
//We don't want to keep adding them back if a user deleted them on purpose.
|
|
|
|
public void Init_should_skip_if_any_profiles_already_exist()
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IQualityProfileRepository>()
|
|
|
|
.Setup(s => s.All())
|
|
|
|
.Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList());
|
|
|
|
|
2013-04-13 02:28:05 +03:00
|
|
|
Subject.Handle(new ApplicationStartedEvent());
|
2013-02-27 06:19:22 +03:00
|
|
|
|
|
|
|
Mocker.GetMock<IQualityProfileRepository>()
|
|
|
|
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|