mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Adds unit tests improving domain project code coverage
This commit is contained in:
1 parent
208f102070
commit
0ec6eb7ab4
25 files changed
+1577
-12
No files matched your search
+39
@@ -95,6 +95,45 @@ public class LibraryTests
|
||||
Assert.Equal(id, result.Value.Id.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenGivenPreExistingIdAndInvalidContentLocation_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
Guid id = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
Result<Library> result = Library.Create(
|
||||
_libraryIdFixture.Create(id),
|
||||
_userIdFixture.Create(),
|
||||
"My Library",
|
||||
LibraryType.Book,
|
||||
[""],
|
||||
null,
|
||||
isEnabled: true,
|
||||
isLocked: false,
|
||||
canDownloadMetadataFromWeb: true,
|
||||
shouldSaveMetadataInMediaDirectories: false,
|
||||
shouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
[]);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Lumina.Domain.Common.Errors.Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithValidData_ShouldLeaveCoverImageSourcePathUnset()
|
||||
{
|
||||
// Arrange
|
||||
Library library = _libraryFixture.Create();
|
||||
|
||||
// Act
|
||||
string? coverImageSourcePath = library.CoverImageSourcePath;
|
||||
|
||||
// Assert
|
||||
Assert.Null(coverImageSourcePath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalledWithContentLocations_ShouldCreateFileSystemPathIdForEachLocation()
|
||||
{
|
||||
|
||||
+17
@@ -100,6 +100,23 @@ public class MediaLibrariesScanProgressTrackerTests
|
||||
Assert.Equal(100, progressResult.Value.OverallProgressPercentage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateScanProgress_WhenScanIsAlreadyCompleted_ShouldReturnError()
|
||||
{
|
||||
// Arrange
|
||||
LibraryId libraryId = _libraryIdFixture.Create();
|
||||
MediaLibraryScanCompositeId compositeId = _mediaLibraryScanCompositeIdFixture.Create();
|
||||
_sut.InitializeScanProgress(libraryId, compositeId, totalJobs: 1);
|
||||
_sut.UpdateScanProgress(libraryId, compositeId);
|
||||
|
||||
// Act
|
||||
Result<Updated> result = _sut.UpdateScanProgress(libraryId, compositeId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.LibraryScanning.CompletedScanJobsCountCantExceedTotalScanJobsCount, result.FirstError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateScanJobProgress_WhenScanExists_ShouldUpdateCurrentJobProgress()
|
||||
{
|
||||
|
||||
+30
@@ -35,9 +35,39 @@ public class MediaLibraryScannerFactoryTests
|
||||
|
||||
[Theory]
|
||||
[InlineData(LibraryType.EBook)] // eBook scanner is not implemented
|
||||
[InlineData(LibraryType.ComicBook)] // comic book scanner is not implemented
|
||||
[InlineData(LibraryType.Magazine)] // magazine scanner is not implemented
|
||||
[InlineData(LibraryType.Newspaper)] // newspaper scanner is not implemented
|
||||
[InlineData(LibraryType.Manga)] // manga scanner is not implemented
|
||||
[InlineData(LibraryType.GraphicNovel)] // graphic novel scanner is not implemented
|
||||
[InlineData(LibraryType.AcademicPaper)] // academic paper scanner is not implemented
|
||||
[InlineData(LibraryType.SheetMusic)] // sheet music scanner is not implemented
|
||||
[InlineData(LibraryType.Movie)] // movie scanner is not implemented
|
||||
[InlineData(LibraryType.TvShow)] // TV show scanner is not implemented
|
||||
[InlineData(LibraryType.Documentary)] // documentary scanner is not implemented
|
||||
[InlineData(LibraryType.Anime)] // anime scanner is not implemented
|
||||
[InlineData(LibraryType.ConcertVideo)] // concert video scanner is not implemented
|
||||
[InlineData(LibraryType.TutorialVideo)] // tutorial video scanner is not implemented
|
||||
[InlineData(LibraryType.HomeVideo)] // home video scanner is not implemented
|
||||
[InlineData(LibraryType.YouTubeVideo)] // YouTube video scanner is not implemented
|
||||
[InlineData(LibraryType.MusicVideo)] // music video scanner is not implemented
|
||||
[InlineData(LibraryType.LiveRecordingVideo)] // live recording video scanner is not implemented
|
||||
[InlineData(LibraryType.InterviewVideo)] // interview video scanner is not implemented
|
||||
[InlineData(LibraryType.CoverSongVideo)] // cover song video scanner is not implemented
|
||||
[InlineData(LibraryType.PodcastVideo)] // podcast video scanner is not implemented
|
||||
[InlineData(LibraryType.Music)] // music scanner is not implemented
|
||||
[InlineData(LibraryType.Audiobook)] // audiobook scanner is not implemented
|
||||
[InlineData(LibraryType.LiveRecordingAudio)] // live recording audio scanner is not implemented
|
||||
[InlineData(LibraryType.InterviewAudio)] // interview audio scanner is not implemented
|
||||
[InlineData(LibraryType.CoverSongAudio)] // cover song audio scanner is not implemented
|
||||
[InlineData(LibraryType.Remix)] // remix scanner is not implemented
|
||||
[InlineData(LibraryType.SoundEffect)] // sound effect scanner is not implemented
|
||||
[InlineData(LibraryType.PodcastAudio)] // podcast audio scanner is not implemented
|
||||
[InlineData(LibraryType.Photo)] // photo scanner is not implemented
|
||||
[InlineData(LibraryType.Playlist)] // playlist scanner is not implemented
|
||||
[InlineData(LibraryType.Collection)] // collection scanner is not implemented
|
||||
[InlineData(LibraryType.Subtitles)] // subtitles scanner is not implemented
|
||||
[InlineData(LibraryType.Lyrics)] // lyrics scanner is not implemented
|
||||
public void CreateLibraryScanner_WhenLibraryTypeIsNotImplemented_ShouldThrowNotImplementedException(LibraryType libraryType)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+18
@@ -197,4 +197,22 @@ public class MediaLibraryScanProgressTests
|
||||
// Assert
|
||||
Assert.NotEqual(firstResult, secondResult);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToString_WhenCalled_ShouldReturnFormattedProgressString()
|
||||
{
|
||||
// Arrange
|
||||
MediaLibraryScanJobProgress currentJobProgress = _mediaLibraryScanJobProgressFixture.Create(completedItems: 3, totalItems: 10, currentOperation: "Hashing files");
|
||||
MediaLibraryScanProgress scanProgress = _mediaLibraryScanProgressFixture.Create(
|
||||
completedJobs: 2,
|
||||
totalJobs: 5,
|
||||
status: LibraryScanJobStatus.Running,
|
||||
currentJobProgress: Optional<MediaLibraryScanJobProgress>.Some(currentJobProgress));
|
||||
|
||||
// Act
|
||||
string result = scanProgress.ToString();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("CompletedJobs: 2; TotalJobs: 5; CurrentJobProgress: CompletedItems: 3; TotalItems: 10; CurrentOperation: Hashing files", result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user