1
0
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:
kay.one 2013-06-05 23:06:50 -07:00
parent cc88840cf2
commit cc0ed59e7b
3 changed files with 52 additions and 2 deletions

View File

@ -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" />

View 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());
}
}
}

View File

@ -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());
}
}
}
}