added quality size repo fixture

pull/6/head
kay.one 12 years ago
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" />

@ -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 @@ namespace NzbDrone.Core.Qualities
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…
Cancel
Save