|
|
|
@ -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 GivenBookFile()
|
|
|
|
|
{
|
|
|
|
|
Db.Insert(_bookFiles[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GivenTrackFile()
|
|
|
|
|
private void GivenTwoBookFiles()
|
|
|
|
|
{
|
|
|
|
|
Db.Insert(_trackFile);
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
GivenBookFile();
|
|
|
|
|
|
|
|
|
|
var stats = Subject.AuthorStatistics();
|
|
|
|
|
|
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
|
stats.First().SizeOnDisk.Should().Be(_bookFiles[0].Size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_count_book_with_two_files_as_one_book()
|
|
|
|
|
{
|
|
|
|
|
GivenTrackFile();
|
|
|
|
|
GivenTwoBookFiles();
|
|
|
|
|
|
|
|
|
|
var stats = Subject.AuthorStatistics();
|
|
|
|
|
|
|
|
|
|
Db.All<BookFile>().Should().HaveCount(2);
|
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
|
stats.First().SizeOnDisk.Should().Be(_trackFile.Size);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|