mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
+40
-13
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
@@ -17,7 +18,7 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
private Author _author;
|
||||
private Book _book;
|
||||
private Edition _edition;
|
||||
private BookFile _trackFile;
|
||||
private List<BookFile> _bookFiles;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -39,17 +40,24 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
.BuildNew();
|
||||
Db.Insert(_edition);
|
||||
|
||||
_trackFile = Builder<BookFile>.CreateNew()
|
||||
_bookFiles = Builder<BookFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(x => x.Id = 0)
|
||||
.With(e => e.Author = _author)
|
||||
.With(e => e.Edition = _edition)
|
||||
.With(e => e.EditionId == _edition.Id)
|
||||
.With(e => e.EditionId = _edition.Id)
|
||||
.With(e => e.Quality = new QualityModel(Quality.MP3))
|
||||
.BuildNew();
|
||||
.BuildList();
|
||||
}
|
||||
|
||||
private void GivenTrackFile()
|
||||
private void GivenBookFile()
|
||||
{
|
||||
Db.Insert(_trackFile);
|
||||
Db.Insert(_bookFiles[0]);
|
||||
}
|
||||
|
||||
private void GivenTwoBookFiles()
|
||||
{
|
||||
Db.InsertMany(_bookFiles);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -61,7 +69,7 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_include_unmonitored_track_in_track_count()
|
||||
public void should_not_include_unmonitored_book_in_book_count()
|
||||
{
|
||||
var stats = Subject.AuthorStatistics();
|
||||
|
||||
@@ -70,9 +78,9 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_include_unmonitored_track_with_file_in_track_count()
|
||||
public void should_include_unmonitored_book_with_file_in_book_count()
|
||||
{
|
||||
GivenTrackFile();
|
||||
GivenBookFile();
|
||||
|
||||
var stats = Subject.AuthorStatistics();
|
||||
|
||||
@@ -81,7 +89,7 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_size_on_disk_of_zero_when_no_track_file()
|
||||
public void should_have_size_on_disk_of_zero_when_no_book_file()
|
||||
{
|
||||
var stats = Subject.AuthorStatistics();
|
||||
|
||||
@@ -90,14 +98,33 @@ namespace NzbDrone.Core.Test.AuthorStatsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_size_on_disk_when_track_file_exists()
|
||||
public void should_have_size_on_disk_when_book_file_exists()
|
||||
{
|
||||
GivenTrackFile();
|
||||
GivenBookFile();
|
||||
|
||||
var stats = Subject.AuthorStatistics();
|
||||
|
||||
stats.Should().HaveCount(1);
|
||||
stats.First().SizeOnDisk.Should().Be(_trackFile.Size);
|
||||
stats.First().SizeOnDisk.Should().Be(_bookFiles[0].Size);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_count_book_with_two_files_as_one_book()
|
||||
{
|
||||
GivenTwoBookFiles();
|
||||
|
||||
var stats = Subject.AuthorStatistics();
|
||||
|
||||
Db.All<BookFile>().Should().HaveCount(2);
|
||||
stats.Should().HaveCount(1);
|
||||
|
||||
var bookStats = stats.First();
|
||||
|
||||
bookStats.TotalBookCount.Should().Be(1);
|
||||
bookStats.BookCount.Should().Be(1);
|
||||
bookStats.AvailableBookCount.Should().Be(1);
|
||||
bookStats.SizeOnDisk.Should().Be(_bookFiles.Sum(x => x.Size));
|
||||
bookStats.BookFileCount.Should().Be(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user