You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs

69 lines
2.0 KiB

using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.MediaFiles;
12 years ago
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework;
12 years ago
using NzbDrone.Core.Tv;
12 years ago
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MediaFileTests
{
[TestFixture]
12 years ago
public class MediaFileRepositoryFixture : DbTest<MediaFileRepository, EpisodeFile>
{
[Test]
public void get_files_by_series()
{
var files = Builder<EpisodeFile>.CreateListOfSize(10)
.All()
.With(c => c.Id = 0)
12 years ago
.With(c => c.Quality =new QualityModel(Quality.Bluray720p))
.Random(4)
.With(s => s.SeriesId = 12)
12 years ago
.BuildListOfNew();
Db.InsertMany(files);
var seriesFiles = Subject.GetFilesBySeries(12);
seriesFiles.Should().HaveCount(4);
seriesFiles.Should().OnlyContain(c => c.SeriesId == 12);
}
[Test]
public void GetFileByPath_should_return_null_if_file_does_not_exist_in_database()
{
Subject.GetFileByPath(@"C:\Test\EpisodeFile.avi").Should().BeNull();
}
12 years ago
[Test]
public void exists_should_return_false_if_file_doesnt_exist()
{
Subject.Exists(@"C:\Test\EpisodeFile.avi").Should().BeFalse();
}
[Test]
public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
{
12 years ago
var path = @"C:\Test\EpisodeFile.avi".AsOsAgnostic();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Id = 0)
12 years ago
.With(f => f.Path = path.CleanFilePath())
.Build();
12 years ago
Subject.Insert(episodeFile);
var file = Subject.GetFileByPath(path);
//Resolve
file.Should().NotBeNull();
12 years ago
file.Path.Should().Be(path.CleanFilePath());
}
}
}