mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
added quality size repo fixture
This commit is contained in:
parent
cc88840cf2
commit
cc0ed59e7b
@ -150,6 +150,7 @@
|
||||
<Compile Include="MediaFileTests\EpisodeFileMoverFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TracktProxyFixture.cs" />
|
||||
<Compile Include="NotificationTests\NotificationServiceFixture.cs" />
|
||||
<Compile Include="Qualities\QualitySizeRepositoryFixture.cs" />
|
||||
<Compile Include="Qualities\QualityProfileRepositoryFixture.cs" />
|
||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="Qualities\QualityFixture.cs" />
|
||||
|
41
NzbDrone.Core.Test/Qualities/QualitySizeRepositoryFixture.cs
Normal file
41
NzbDrone.Core.Test/Qualities/QualitySizeRepositoryFixture.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace NzbDrone.Core.Test.Qualities
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class QualitySizeRepositoryFixture : DbTest<QualitySizeRepository, QualitySize>
|
||||
{
|
||||
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.SetConstant<IQualitySizeRepository>(Subject);
|
||||
Mocker.Resolve<QualitySizeService>().Handle(new ApplicationStartedEvent());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_get_quality_size_by_id()
|
||||
{
|
||||
var size = Subject.GetByQualityId(Quality.Bluray1080p.Id);
|
||||
|
||||
size.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_with_id_if_not_exist()
|
||||
{
|
||||
var id = 123;
|
||||
Assert.Throws<InvalidOperationException>(()=> Subject.GetByQualityId(id)).Message.Contains(id.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Data;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
@ -19,7 +20,14 @@ public QualitySizeRepository(IDatabase database, IMessageAggregator messageAggre
|
||||
|
||||
public QualitySize GetByQualityId(int qualityId)
|
||||
{
|
||||
return Query.Single(q => q.QualityId == qualityId);
|
||||
try
|
||||
{
|
||||
return Query.Single(q => q.QualityId == qualityId);
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
throw new InvalidOperationException("Sequence contains no element with qualityId = " + qualityId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user